Skip to content

Instantly share code, notes, and snippets.

@cjgiridhar
Last active January 23, 2019 06:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cjgiridhar/b6555c831ee6d15b6abdd8dfaf094bf7 to your computer and use it in GitHub Desktop.
Save cjgiridhar/b6555c831ee6d15b6abdd8dfaf094bf7 to your computer and use it in GitHub Desktop.
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