25 lines
380 B
Go
25 lines
380 B
Go
|
package main
|
||
|
|
||
|
import (
|
||
|
"fmt"
|
||
|
)
|
||
|
|
||
|
func main() {
|
||
|
fmt.Println("No parantheses, braces required")
|
||
|
val := 1
|
||
|
if val == 0 {
|
||
|
fmt.Println("1")
|
||
|
} else if val == 1 {
|
||
|
fmt.Println("2")
|
||
|
} else {
|
||
|
fmt.Println("3")
|
||
|
}
|
||
|
|
||
|
fmt.Println("Also you can execute short statement before condition")
|
||
|
if val2 := 1; val2 > 0 {
|
||
|
fmt.Println(val2)
|
||
|
}
|
||
|
// fmt.Println(val2) // ERROR, out of scope
|
||
|
|
||
|
}
|