Quick way to check if all items in a Ruby array are unique

ruby

Solution

# As simple as possible:
not_unique == not_unique.uniq

# or perhaps
not_unique.size == not_unique.uniq.size

Problem

I'm looking for a quick and easy way to check if all the items in an array are unique. ``` unique = ['one', 'two'] unique = [] not_unique = ['one', 'one', 'two'] ```

Original source