Skip to Content
Learn Go: Conditionals
Logical Operators (Not)

Our last logical operator is the not (!) operator. It negates (reverses) the value of a boolean. For example:

bored := true fmt.Println(!bored) // Prints false tired := false; fmt.Println(!tired) // Prints true

Notice that the ! operator will either take a true value and pass back false, or it will take a false value and pass back true.

Let’s see how to incorporate the ! operator.



In main.go add a ! operator to the if condition so that "What are we waiting for??" is printed to the terminal.

Folder Icon

Take this course for free

Already have an account?