Boolean type

In Go, Boolean binary values are stored using the bool type. Although a variable of type bool is stored as a 1-byte value, it is not, however, an alias for a numeric value. Go provides two pre-declared literals, true and false, to represent Boolean values as shown in the following example:

package main 
import "fmt" 
 
func main() { 
   var readyToGo bool = false 
   if !readyToGo { 
       fmt.Println("Come on") 
   } else { 
       fmt.Println("Let's go!") 
   } 
} 

golang.fyi/ch04/bool.go

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.14.131.212