groovy – Collection Operators – Create a new list using collect

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 = map.collect { it.value } // ['FOO', 'BAR', 'BAZ']

The above example is equivalent to calling map.keySet() and map.values()

if you want to reproduce, please indicate the source:
groovy – Collection Operators – Create a new list using collect - CodeDay