It could happen that you find yourself in a position where you have an array
that container duplicated items and you actually need to remove those duplicates and return only unique items.
This is how you can do it.
def myArray = [1,20,40,10,20,40,50,20]
As you can see in myArray we have number 20 multiple times also 40
appears two times.
Groovy has a method called unique() , using this function on array
it will remove any duplication.
def myUniqueArray = myArray.unique()
The output will be:
To be noted that myUniqueArray it is also an array.