Skip to content

Instantly share code, notes, and snippets.

@leejarvis

leejarvis/blah Secret

Created December 2, 2011 17:45
Show Gist options
  • Save leejarvis/51aa9921ea38ce58e6ea to your computer and use it in GitHub Desktop.
Save leejarvis/51aa9921ea38ce58e6ea to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
require 'set'
class Foo
def initialize(name)
@name = name
end
def eql?(other)
self.hash == other.hash
end
def hash
@name.hash
end
end
set = Set.new
set << Foo.new('foo')
set << Foo.new('foo')
set << Foo.new('bar')
p set #=> #<Set: {#<Foo:0x00000100821698 @name="foo">, #<Foo:0x000001008215f8 @name="bar">}>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment