Logo

Programming-Idioms

History of Idiom 172 > diff from v23 to v24

Edit summary for version 24 by andyjduncan:
New Groovy implementation by user [andyjduncan]

Version 23

2020-10-10, 12:17:58

Version 24

2020-10-10, 12:20:58

Idiom #172 Insert entry in map

Insert value v for key k in map m.

Idiom #172 Insert entry in map

Insert value v for key k in map m.

Variables
v,k,m
Variables
v,k,m
Extra Keywords
associative
Extra Keywords
associative
Code
m[k] = v
Comments bubble
Use index notation. The value of k is used as the key. This delegates to the regular putAt method.
Doc URL
https://groovy-lang.org/groovy-dev-kit.html#_adding_or_removing_elements_2
Demo URL
https://groovyconsole.appspot.com/script/5083320211734528