Skip to content

Instantly share code, notes, and snippets.

@rdavila
Created October 26, 2012 17:02
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 rdavila/3959936 to your computer and use it in GitHub Desktop.
Save rdavila/3959936 to your computer and use it in GitHub Desktop.
class A
attr_accessor :foo
def ==(other)
other.is_a?(B) && self.foo == other.foo
end
end
class B
attr_accessor :foo
end
# probando en consola
>> a = A.new
=> #<A:0x007f90159ea2d0>
>> a.foo = 3
=> 3
>> b = B.new
=> #<B:0x007f90158b9f28>
>> b.foo = 3
=> 3
>> a == b
=> true
>> b.foo = 5
=> 5
>> a == b
=> false
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment