Sunday, 13 January 2019

Groovy: Precedence of Logical Operators


Logical ! has higher precedence over Logical &&
!true && false
=> false && false (Since ! has higher precedence over &&)
=> false

Logical && has higher precedence over Logical ||
true || true && false
=> true || false
=> true

HelloWorld.groovy
a = (!true && false)
b = (true || true && false)

println "a : ${a}"
println "b : ${b}"

Output
a : false
b : true

Previous                                                 Next                                                 Home

No comments:

Post a Comment