Mingtao's Java World
Wednesday, 6 April 2016
Groovy Map << [key: value] vs Map << [(key): value]
Note the difference between a key wrapped with () and without. If without parentheses, the key will be literal 'key'. With parentheses, the key is the value 100.
def key = 100 def map = [:] map << [key:2] println map map << [(key):2] println map
No comments:
Post a Comment
Newer Post
Older Post
Home
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment