I have a class with several properties and I have several instances.
How can verify if two instances have the exact same values (even though they are different places in memory)
In other words how can I compare prs1, prs2, and prs3 in the following example and get true?
class Person property name : String property height : Float64 def initialize(@name, @height) end end prs1 = Person.new(name: "Jane", height: 173.1) prs2 = prs1.dup prs3 = Person.new(name: "Jane", height: 173.1) p! prs1 p! prs2 p! prs3 puts prs1 == prs2 # false puts prs1 == prs3 # false
and BTW Class - Crystal 1.0.0 indicates there is a
clone method as well, but when I tried to write clone instead of dup I got:
Error: undefined method 'clone' for Person