SyntaxFix
Write A Post
Hire A Developer
Questions
The reason you get a Null Pointer Exception is because there is no key likesZZZ in your second example. Try:
def mymap = [name:"Gromit", likes:"cheese", id:1234] def x = mymap.find{ it.key == "likes" }.value if(x) println "x value: ${x}"