Sunday 13 January 2019

Groovy: Not (!) operator


Not operator is represented by !, it is used to evaluate the boolean expressions.

HelloWorld.groovy

a = true

if(!a){
	println "a is evaluated to false"
}else{
	println "a is evaluated to true"
}

b = ""

if(!b){
	println "b is an empty string"
}else{
	println "b is not an empty string"
}

Output
a is evaluated to true
b is an empty string

Previous                                                 Next                                                 Home

No comments:

Post a Comment