13. Boolean
Last updated
Boolean has only two possible values, true and false
Conditions and comparison operators needs value to be bool Type.
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:
var shouldBe bool = true
var shouldBe = true
shouldBe :=trueZero value for bool is false
Last updated