The Go ! operator means not. It flips a boolean value.
isSunny := true
if !isSunny {
fmt.Println("Learning to code")
} else {
fmt.Println("Going to the beach")
}
Since isSunny is true, !isSunny is false, so the else branch runs.
Assignment
Use ! to check when it is not sunny.
Free plan: 30 tutor messages. PRO is unlimited.
Saved
Ctrl + Enter to check
