Groovy web console

subscribe to the feed Subscribe
to this
site

direct-assignment

Published 1 month ago by Anonymous
Actions  ➤ Edit in console Back to console Show/hide line numbers View recent scripts
List<Map> source = [[value: 1]]
List<Map> mapList = []

println "Using direct assignment"
for(int i = 0;i<5;i++){
    def target = source.find{it.value == 1}
    target.put('index', i)
    mapList.add(target)
}
mapList.each{
    println it.hashCode()
}