Tutorial by Examples: collectentries

From lists def lst = ['foo', 'bar', 'baz'] // for each entry return a list containing [key, value] lst.collectEntries { [it, it.toUpperCase()] } // [foo: FOO, bar: BAR, baz: BAZ] // another option, return a map containing the single entry lst.collectEntries { [(it): it.toUpperCase()] } // [...

Page 1 of 1