Skip to content

Instantly share code, notes, and snippets.

@rdavila
Created October 26, 2012 17:02

Revisions

  1. @rudasa rudasa created this gist Oct 26, 2012.
    27 changes: 27 additions & 0 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,27 @@
    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