Groovy web console

subscribe to the feed Subscribe
to this
site

groupIndex

Published 3 weeks ago by Anonymous
Actions  ➤ Edit in console Back to console Show/hide line numbers View recent scripts
L:{
    int groupIndex = 0
    def out = (
        ["abc", "def"]
    ).collectEntries {
        int id = groupIndex++
        [(id): [id: id, name: it]]
    }
    
    println out
}

P:{
    int groupIndex = 0
    def out = (
        ["abc", "def"]
    ).collectEntries() {
        [(it): groupIndex++]
    }
    
    println out
}