Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Primitive Data Types in Go - Boolean
package main
import "fmt"
func main() {
/* Assignment */
var isBool = true
var isActive bool //is_active is set to false
var isTrue = 1 <= 5 // as 1<=5 is true, isTrue variable is set to true
/* Short circuiting */
var res = 1 > 5 && 3 == 5 // First operands evaluates to false, so second is not evaluated
var out = 2*2 == 4 || 10%3 == 0 // Second operand is not evaluated as first is true
fmt.Println(isBool, isActive, isTrue, res, out)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.