Sreejata Pal
Sreejata Pal

Reputation: 13

How to retrieve value against key from map

I am able to populate a hash map using groovy. How can I now get the corresponding value against a key from that hash map? Please note, I have to pass the key in a variable while doing the lookup.

Upvotes: 0

Views: 110

Answers (1)

tim_yates
tim_yates

Reputation: 171184

You mean like:

def map = [tim: 'yates']

def key = 'tim'

println map[key]

?

Upvotes: 1

Related Questions