def lst = ['foo', 'bar', 'baz']
lst.collect { it } // ['foo', 'bar', 'baz']
lst.collect { it.toUpperCase() } // ['FOO', 'BAR', 'BAZ']
To collect keys or values from a maps
def map = [foo: 'FOO', bar: 'BAR', baz: 'BAZ']
def keys = map.collect { it.key } // ['foo', 'bar', 'baz']
def vals = m...