Created
March 16, 2011 16:50
-
-
Save zdavatz/872811 to your computer and use it in GitHub Desktop.
persistable.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def ==(other) # :nodoc: | |
super(other.odba_instance) | |
end |
This is the definition of '==' method.
Actually, it is expected to be used for the comparison of instances
if the instance 'equals' to the other.
Usually, test1 and test2 are different object, so
(test1 == test2) becomes always 'false'
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
class Test
attr_accessor :aaa
def ==(other)
@aaa == other.aaa
end
end
test1 = Test.new
test2 = Test.new
test1.aaa = 100
test2.aaa = 200
p (test1 == test2) #=> false
test2.aaa = 100
p (test1 == test2) #=> true