Skip to content

Instantly share code, notes, and snippets.

@TimLang
Last active August 29, 2015 13:57
Show Gist options
  • Save TimLang/9542800 to your computer and use it in GitHub Desktop.
Save TimLang/9542800 to your computer and use it in GitHub Desktop.
ruby array uniq?
class Array
def uniq?
hash = {}
self.each do |e|
obj = block_given? ? yield(e) : e
return false if hash[obj]
hash[obj] = obj
end
hash.size == self.size
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment