Groovy web console

subscribe to the feed Subscribe
to this
site
map stuff (via #groovywebconsole)
tweet this snippet Tweet
this
script

map stuff

Published 3 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]