Empty list evaluate to false, and non-empty list
evaluates to true.
HelloWorld.groovy
emptyList = [] nonEmptyList = [null] if(emptyList){ println "emptyList evaluated to true" }else{ println "emptyList evaluated to false" } if(nonEmptyList){ println "nonEmptyList evaluated to true" }else{ println "nonEmptyList evaluated to false" }
Output
emptyList evaluated to false
nonEmptyList evaluated to true
No comments:
Post a Comment