"If"의 두 판 사이의 차이

2번째 줄: 2번째 줄:


==Bash==
==Bash==
[[분류:Bash]]
{{다른뜻|Bash if}}
{{다른뜻|Bash if}}
<source lang='bash'>
<source lang='bash'>
15번째 줄: 16번째 줄:


==CMD==
==CMD==
[[분류:Cmd]]
<source lang='bash'>
<source lang='bash'>
set my_name=John Smith
set my_name=John Smith
IF "%my_name%"=="John Smith" ECHO my_name is John Smith
IF "%my_name%"=="John Smith" ECHO my_name is John Smith
</source>
==Perl==
[[분류:Perl]]
<source lang='perl'>
if ( 43 > 42 ) {
printf("hello\n");
printf("world\n");
}
printf("hello\n") if (43 > 42);
</source>
</source>


==PHP==
==PHP==
[[분류:PHP]]
{{참고|PHP if}}
{{참고|PHP if}}
<source lang='php'>
<source lang='php'>
35번째 줄: 49번째 줄:


==Python==
==Python==
[[분류:Python]]
<source lang='python'>
<source lang='python'>
if 43 > 42:
if 43 > 42:
48번째 줄: 63번째 줄:


==Ruby==
==Ruby==
[[분류:Ruby]]
<source lang='Ruby'>
<source lang='Ruby'>
if 43 > 42
if 43 > 42
74번째 줄: 90번째 줄:
* [[제어문]]
* [[제어문]]
* [[자바키워드]]
* [[자바키워드]]
[[분류:Bash]]
[[분류:Cmd]]
[[분류:PHP]]
[[분류:Python]]
[[분류:Ruby]]

2018년 8월 3일 (금) 16:54 판

1 Bash

  다른 뜻에 대해서는 Bash if 문서를 참조하십시오.
He="John Smith"
if [ "$He" = "John Smith" ]; then
	echo "He is John Smith"
else
	echo "He is not John Smith"
fi
# He is John Smith

2 CMD

set my_name=John Smith
IF "%my_name%"=="John Smith" ECHO my_name is John Smith

3 Perl

if ( 43 > 42 ) {
	printf("hello\n");
	printf("world\n");
}

printf("hello\n") if (43 > 42);

4 PHP

if(43>42) {
	echo('hello');
	echo('world');
}
// helloworld
if(43>42) echo('hello');
// hello

5 Python

if 43 > 42:
	print('hello')
	print('world')
# hello
# world
if 43 > 42: print ('hello')
# hello

6 Ruby

if 43 > 42
	print 'hello'
end
# hello
  • one-line
print 'hello' if true
# hello
print 'world' if false

7 같이 보기

문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}