Unique Elements
# uniq method removes duplicates from a single array, creating a new array.
# uniq! changes the array itself, in place.
shopping_list = %w[ cheese bread crackers potatoes carrots cheese ]
# => ["cheese", "bread", "crackers", "potatoes", "carrots", "cheese"]
shopping_list.uniq!=> ["cheese", "bread", "crackers", "potatoes", "carrots"]
Related examples in the same category