Groovy web console

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

merging things

Published 2 months ago by hardik
Actions  ➤ Edit in console Back to console Show/hide line numbers View recent scripts
Integer updateInteger(oldValue, newValue){
    if(newValue instanceof Integer){
        return oldValue+newValue;
    }else{
                //logger.info(newValue +" total is not of integer type")
                return oldValue;
            }
}
languages = [["name":"en", total: 10]]
languages2 = [["name":"in", total: 10]]
for(newLang in languages2){
    boolean found = false
    for(langStored in languages){
        if(langStored.name == newLang.name){
                langStored.total = updateInteger(langStored.total, newLang.total)                
                boolean found = true
                break;
        }
    }
    if(!found){
        found.
    }
}
println languages2

boolean x = true
println !x