Comment on page
13. Boolean
Boolean has only two possible values,
true
and false
Conditions and comparison operators needs value to be bool Type.
main.go
package main
import "fmt"
func main() {
var shouldGo bool = true
if shouldGo {
fmt.Println("I should Go!")
}
}
Boolean are declared using one of the following ways:
main.go
var shouldBe bool = true
var shouldBe = true
shouldBe :=true
Zero value for bool is
false
Last modified 4yr ago