shad-go/lectures/01-basics/scope/if.go

17 lines
234 B
Go
Raw Normal View History

2020-02-20 14:40:51 +00:00
package main
import "fmt"
func f() int { return 0 }
func g(x int) int { return x }
func example() {
if x := f(); x == 0 {
fmt.Println(x)
} else if y := g(x); x == y {
fmt.Println(x, y)
} else {
fmt.Println(x, y)
}
}