The first method calls plusin a variablelst
As we can see from the documentation , this will be:
Create a collection as a union Collection and object.
, , lst ( ) . (, lst )
, updateList:
public updateList(lst) {
lst += "a" // calls plus, creates a new list, and returns this new list.
// lst (outside the context of this method) is unmodified
}
List lst = []
println( updateList(lst) )
add, java.
public updateList(lst) {
lst.add "a"
}
, lst
add leftShift:
public updateList(lst) {
lst << "a"
}
: ( Groovy )
public static <T> Collection<T> leftShift(Collection<T> self, T value) {
self.add(value);
return self;
}