Groovy web console

subscribe to the feed Subscribe
to this

map stuff

Published 6 months ago by sven
Actions  ➤ Edit in console Back to console Show/hide line numbers View recent scripts
def map = [a:1,b:2,c:3,d:5]

def toRemove = ['a', 'b', 'c']
def removedEntry  = toRemove.collectEntries{ [it, map.remove(it)] }
assert map == [d:5]
assert removedEntry.values() as List == [1, 2, 3]
assert removedEntry == [a:1,b:2,c:3]