def lst = ['foo', 'bar', 'baz']
lst.collect { it } // ['foo', 'bar', 'baz']
lst.collect { it.toUpperCase() } // ['FOO', 'BAR', 'BAZ']
def map = [foo: 'FOO', bar: 'BAR', baz: 'BAZ']
def keys = map.collect { it.key } // ['foo', 'bar', 'baz']
def vals = map.collect { it.value } // ['FOO', 'BAR', 'BAZ']
The above example is equivalent to calling map.keySet()
and map.values()