- else
1 Bash[ | ]
Bash
Copy
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[ | ]

Go
CPU
-1.0s
MEM
-0M
-1.0s
Copy
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")
}
}
7 is odd 8 is divisible by 4 9 has 1 digit
3 PHP[ | ]

PHP
Copy
if ( 1 == 1 ) {
echo "True";
} else {
echo "False";
}
# True
PHP
Copy
if ( 1 == 2 ):
echo "True";
else:
echo "False";
endif;
# False
4 Python[ | ]
Python
Copy
if 1==1:
print(True)
else:
print(False)
# True
Python
Copy
if 1==2:
print(True)
else:
print(False)
# False
5 Perl[ | ]
Perl
Copy
if ( 1 eq 1 ) {
print "True";
} else {
print "False";
}
# True
Perl
Copy
if ( 1 eq 2 ) {
print "True";
} else {
print "False";
}
# False
6 Ruby[ | ]
Ruby
Copy
if 43 > 42
puts 'true'
else
puts 'false'
end
# true
7 같이 보기[ | ]
로그인하시면 댓글을 쓸 수 있습니다.
- 분류 댓글:
- Python (25)
- PHP (8)
- Bash (3)
리눅스 Python 2.7 컴파일 설치 ― …리눅스 Python 2.7 컴파일 설치 ― …리눅스 Python 2.7 컴파일 설치 ― …리눅스 Python 2.7 컴파일 설치 ― …리눅스 Python 2.7 컴파일 설치 ― Jmnote리눅스 Python 2.7 컴파일 설치 ― ㅇㅇㅇ미운코딩새끼 ― 승호 도령미운코딩새끼 ― 불탄고등어미운코딩새끼 ― 김레이미운코딩새끼 ― 호박이미운코딩새끼 ― Junhg0211미운코딩새끼 ― 김왼손미운코딩새끼 ― 용딘이미운코딩새끼 ―Pinkcrimson
유기농냠냠파이썬 ― 호박유기농냠냠파이썬 ― 이에스유기농냠냠파이썬 ― 이승현파이썬 global ― Jmnote파이썬 global ― John Jeong파이썬 global ― Jmnote파이썬 global ― John Jeong파이썬 global ― John Jeong파이썬 global ― John Jeong파이썬 global ― Jmnote파이썬 global ― John Jeong