Skip to content

Instantly share code, notes, and snippets.

@practicingruby
Created February 23, 2012 05:02
Show Gist options
  • Select an option

  • Save practicingruby/1890408 to your computer and use it in GitHub Desktop.

Select an option

Save practicingruby/1890408 to your computer and use it in GitHub Desktop.
class A
def initialize(array)
@data = array
end
def eql?(other)
hash == other.hash
end
alias_method :==, :eql?
def hash
@data.hash
end
end
a = A.new([1,2,3])
b = A.new([1,2,3])
p a == b
p a.hash == b.hash
p a.eql?(b)
h = {}
h[a] = :yaay
p h[b]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment