Mark McGranaghan ae112de5ae if-else
2012-09-23 12:14:54 -04:00

18 lines
339 B
Go

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