Skip to content

Instantly share code, notes, and snippets.

@toretore
Last active August 29, 2015 13:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save toretore/9078144 to your computer and use it in GitHub Desktop.
Save toretore/9078144 to your computer and use it in GitHub Desktop.
class Foo
attr_reader :v
def initialize(v)
@v = v
end
def hash
v.hash
end
def eql?(o)
puts "Foo#eql? called"
if o.is_a?(self.class)
o.v.eql?(v)
else
o.eql?(v)
end
end
end
h = {}
f = Foo.new('hello')
h[f] = 'world'
h['hello'] = 'jupiter'
p h[f]
p h['hello']
p h
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment