There are multiple ways of adding items to a list in groovy. One of them is using the << operator:
<<
def list = [] list << "item"
Another is using + or +=:
+
+=
list += "a" + ["b", "c", "d"]
<< is mutating while += is not - it creates a new list.
Sourcearrow-up-right
Last updated 4 years ago