Skip to content

Instantly share code, notes, and snippets.

@janxious
Created October 22, 2010 21:01
Show Gist options
  • Save janxious/641364 to your computer and use it in GitHub Desktop.
Save janxious/641364 to your computer and use it in GitHub Desktop.
array.rb
class Array
alias :orig_uniq__ :uniq
def uniq(attr = nil)
return orig_uniq__ if attr.nil?
[].tap do |c|
found = []
self.each_with_index do |el, i|
val = el.send(attr)
unless found.include? val
found << val
c << self[i]
end
end
end
end
end
@janxious
Copy link
Author

Is this stupid?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment