Last active
January 23, 2019 06:24
-
-
Save cjgiridhar/b6555c831ee6d15b6abdd8dfaf094bf7 to your computer and use it in GitHub Desktop.
Primitive Data Types in Go - Boolean
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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