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() println(myUniqueArray ) The output will be:[1,20,40,10,50] To be noted that myUniqueArray it is also an array. Post navigation Groovy 17 – Multidimensional Array Groovy 19 – Revers Strings