User defined Objects equality always returns false
Class Product def initialize(name, qty) @name = name @qty = qty end def
to_s "#{@name}, #{@qty}" end end
irb> Product.new("Amazon", 3) == Product.new ("Amazon", 3) irb> false
Ruby always returns false for these type of user defined objects which is
wrong, how to make them true if they are equal and false if they are wrong
No comments:
Post a Comment