Booleans and Logic
bool holds true or false. Combine with && || and !. Go has no truthy values, conditions must be booleans.
Example
package main
import "fmt"
func main() {
a, b := true, false
fmt.Println(a && b, a || b, !a)
n := 5
fmt.Println(n > 3 && n < 10)
}Result
false true false true
Exercise
Logical not.
aQuiz Test
These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.