"Else"의 두 판 사이의 차이

 
(다른 사용자 한 명의 중간 판 하나는 보이지 않습니다)
4번째 줄: 4번째 줄:
==Bash==
==Bash==
[[category: Bash]]
[[category: Bash]]
<source lang='bash'>
<syntaxhighlight lang='bash'>
He="John Smith"
He="John Smith"
if [ "$He" = "John Smith" ]; then
if [ "$He" = "John Smith" ]; then
12번째 줄: 12번째 줄:
fi
fi
# He is John Smith
# He is John Smith
</source>
</syntaxhighlight>
 
==Go==
[[분류: Go]]
{{참고|Go if else}}
<syntaxhighlight lang='go' run>
package main
 
import "fmt"
 
func main() {
if 7%2 == 0 {
fmt.Println("7 is even")
} else {
fmt.Println("7 is odd")
}
 
if 8%4 == 0 {
fmt.Println("8 is divisible by 4")
}
 
if num := 9; num < 0 {
fmt.Println(num, "is negative")
} else if num < 10 {
fmt.Println(num, "has 1 digit")
} else {
fmt.Println(num, "has multiple digits")
}
}
</syntaxhighlight>


==PHP==
==PHP==
[[category: PHP]]
[[category: PHP]]
{{참고|PHP else}}
{{참고|PHP else}}
<source lang='php'>
<syntaxhighlight lang='php'>
if ( 1 == 1 ) {
if ( 1 == 1 ) {
echo "True";
echo "True";
24번째 줄: 53번째 줄:
}
}
# True
# True
</source>
</syntaxhighlight>
<source lang='php'>
<syntaxhighlight lang='php'>
if ( 1 == 2 ):
if ( 1 == 2 ):
echo "True";
echo "True";
32번째 줄: 61번째 줄:
endif;
endif;
# False
# False
</source>
</syntaxhighlight>


==Python==
==Python==
[[category: Python]]
[[category: Python]]
<source lang='python'>
<syntaxhighlight lang='python'>
if 1==1:
if 1==1:
print(True)
print(True)
42번째 줄: 71번째 줄:
print(False)
print(False)
# True
# True
</source>
</syntaxhighlight>
<source lang='python'>
<syntaxhighlight lang='python'>
if 1==2:
if 1==2:
print(True)
print(True)
49번째 줄: 78번째 줄:
print(False)
print(False)
# False
# False
</source>
</syntaxhighlight>


==Perl==
==Perl==
[[category: Perl]]
[[category: Perl]]
<source lang='Perl'>
<syntaxhighlight lang='Perl'>
if ( 1 eq 1 ) {
if ( 1 eq 1 ) {
print "True";
print "True";
60번째 줄: 89번째 줄:
}
}
# True
# True
</source>
</syntaxhighlight>
<source lang='Perl'>
<syntaxhighlight lang='Perl'>
if ( 1 eq 2 ) {
if ( 1 eq 2 ) {
print "True";
print "True";
68번째 줄: 97번째 줄:
}
}
# False
# False
</source>
</syntaxhighlight>


==Ruby==
==Ruby==
[[category: Ruby]]
[[category: Ruby]]
<source lang='Ruby'>
<syntaxhighlight lang='Ruby'>
if 43 > 42
if 43 > 42
puts 'true'
puts 'true'
79번째 줄: 108번째 줄:
end
end
# true
# true
</source>
</syntaxhighlight>


==같이 보기==
==같이 보기==

2022년 3월 10일 (목) 11:43 기준 최신판

else

1 Bash[ | ]

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 Go[ | ]

package main

import "fmt"

func main() {
	if 7%2 == 0 {
		fmt.Println("7 is even")
	} else {
		fmt.Println("7 is odd")
	}

	if 8%4 == 0 {
		fmt.Println("8 is divisible by 4")
	}

	if num := 9; num < 0 {
		fmt.Println(num, "is negative")
	} else if num < 10 {
		fmt.Println(num, "has 1 digit")
	} else {
		fmt.Println(num, "has multiple digits")
	}
}

3 PHP[ | ]

if ( 1 == 1 ) {
	echo "True";
} else {
	echo "False";
}
# True
if ( 1 == 2 ):
	echo "True";
else:
	echo "False";
endif;
# False

4 Python[ | ]

if 1==1:
	print(True)
else:
	print(False)
# True
if 1==2:
	print(True)
else:
	print(False)
# False

5 Perl[ | ]

if ( 1 eq 1 ) {
	print "True";
} else {
	print "False";
}
# True
if ( 1 eq 2 ) {
	print "True";
} else {
	print "False";
}
# False

6 Ruby[ | ]

if 43 > 42
	puts 'true'
else
	puts 'false'
end
# true

7 같이 보기[ | ]

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