Skip to content

Instantly share code, notes, and snippets.

@erikh
Created September 2, 2009 03:02
Show Gist options
  • Save erikh/179523 to your computer and use it in GitHub Desktop.
Save erikh/179523 to your computer and use it in GitHub Desktop.
a = [{ :one => 1, :two => 2 }, { :one => 1, :two => 2 }, { :one => 2, :two => 1 }, { :one => 3, :two => 2 }]
def uniq(ary)
b = []
c = ary.dup
while c.length > 1 do
d = c.pop
found = false
c.each do |e|
found ||= d === e
end
b.push(d) unless found
end
b.push(c[0])
end
p uniq(a)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment