Groovy web console

subscribe to the feed Subscribe
to this
site
update list after comparing (via #groovywebconsole)
tweet this snippet Tweet
this
script

update list after comparing

Published 8 months ago by nmrao with tags compare list map
Actions  ➤ Edit in console Back to console Show/hide line numbers View recent scripts
def realData = [[code:60,active:'Y',account:'check'],[code:61,active:'Y',account:'check'],[code:62,active:'Y',account:'check']]  
def sampleData = [[code:60,active:'Y',account:'saving'],[code:61,active:'Y',account:'check'],[code:62,active:'Y',account:'saving']]
realData.collect{rd -> sampleData.find{ it.code == rd.code && (it.account == rd.account ?: (rd.account = it.account))}}
println realData