Skip to content

Instantly share code, notes, and snippets.

@hygull
Created December 9, 2016 02:18
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 hygull/f8810d4f6e56bc4e2e277b33313ae9a0 to your computer and use it in GitHub Desktop.
Save hygull/f8810d4f6e56bc4e2e277b33313ae9a0 to your computer and use it in GitHub Desktop.
operator precedence created by hygull - https://repl.it/Eg5w/4
/*
@Date of creation : 06 Dec 2016.
@Aim of program : Checking operator precedence.
@Coded by : Rishikesh Agrawani.
*/
package main
import "fmt"
func main(){
expIntVal:=2-3+4 //3 or -5
fmt.Println(expIntVal) //3...Don't follow BODMAS Rule here as no parenthesis/brackets/braces are there...Just evaluate from Left -> Right as operators are of same precedence
expBoolVal:= 10<4 && 0>1 //Relatinal operators are executing before logical operator
println(expBoolVal) //false AND false -> false
expBoolVal= 10<4 && 0<1
fmt.Printf("%t",expBoolVal) //false AND true -> false
expBoolVal= 10>4 && 0>1
fmt.Printf("%t",expBoolVal)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment