Skip to content

Instantly share code, notes, and snippets.

@svyatogor
Created May 25, 2012 19:45
Show Gist options
  • Save svyatogor/2790127 to your computer and use it in GitHub Desktop.
Save svyatogor/2790127 to your computer and use it in GitHub Desktop.
class A
attr_accessor :id
def initialize(_id)
self.id = _id
end
def hash
@id.hash
end
def eql?(other)
@id.hash == other.hash
end
alias_method :==, :eql?
end
x = [A.new(1), A.new(2)]
y = [A.new(1), A.new(3)]
p (x&y)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment