Contact: aviboots(AT)netvision.net.il
39,846 questions
51,767 answers
573 users
def map = [name: "Groovy", age: 13, country: "United States", city: "New York"] def f = map.find{it.key == "name"}?.value println f f = map.find{it.key == "abc"}?.value println f /* run: Groovy null */
def map = [name: "Groovy", age: 13, country: "United States", city: "New York"] def key = "name" if(map[key]) { println map[key] } /* run: Groovy */
def map = [name: "Groovy", age: 13, country: "United States", city: "New York"] def key = "name" def f = map[key] ?: "not found" println f key = "abc" f = map[key] ?: "not found" println f /* run: Groovy not found */
def map = [name: "Groovy", age: 13, country: "United States", city: "New York"] println(map.containsKey("name")); println(map.containsKey("abc")); /* run: true false */