gobyexample/009-if-else/009-if-else.go
2012-09-23 12:11:48 -04:00

18 lines
379 B
Go

package main
import "fmt"
func main() {
fmt.Print("7 is ")
if 7 % 2 == 0 { // If/else is straight-forward. Note that there are no
fmt.Println("even") // enclosing parentheses around the condition.
} else { // Also, there is no ternary operator (`?`) in Go.
fmt.Println("odd")
}
}
/*
$ go run 11-if-else.go
7 is odd
*/