Back to Library
Region:
Switch to ID
Intermediate Exercism • go
Booleans
Lesson Overview
# Introduction
About
Booleans in Go are represented by the bool type, which values can be either true or false.
Go supports three boolean operators: ! (NOT), && (AND), and || (OR).
true || false // => true
true && false // => false
!true // => false
The three boolean operators each have a different operator precedence.
As a consequence, they are evaluated in this order: ! first, && second, and finally ||.
If you want to ‘escape’ these rules, you can enclose a boolean expression in parentheses (()), as the parentheses have an even higher operator precedence.
!true && false // => false
!(true && false) // => true
Originally from Exercism go concepts