Groovy web console

subscribe to the feed Subscribe
to this
site

Closures.In.Map.FunctionCall

Published 2 weeks ago by Daniel with tags map closure iteration
Actions  ➤ Edit in console Back to console Show/hide line numbers View recent scripts
def map = [
    'settings' : [ "bootStrap" : { log("Main Settings bootstrap") } ],
    "ac": [
        "settings": [ "bootStrap": { log("AC Settings bootstrap") } ],
        "categories": [
            "Arch": [ "settings": { log("Category bootstrap") } ]
        ]
    ]
]
 
map.each { mapkvp ->
    if (mapkvp.key == "settings") {
        log("Working with Key: $mapkvp.key")
        log("Working with Value: $mapkvp.value")
        mapkvp.value.each { it ->
            it.value()
        }
    }
}

def log(String message) {
    println "$message"
}