Membership operator (in) is used to check whether given
object is present in the collection or not.
HelloWorld.groovy
myHobbies = ["Football", "Cricket", "Chess", "Cycling"] println "is Football my hobby : ${'Football' in myHobbies}" println "is Hockey my hobby : ${'Hockey' in myHobbies}"
Output
is Football my hobby : true
is Hockey my hobby : false
No comments:
Post a Comment