A past puzzle — fully playable. 4 attempts, hints on wrong guesses.
stdle-156.rb
1Point=Struct.new(:x,:y)
2putsPoint.new(1,2)==Point.new(1,2)
3putsPoint.new(1,2)==Point.new(1,3)
Comparisons
Answer & explanation
Console output
true
false
Why
Structs automatically define `==` to compare by type and attribute values, not by object identity. Two separate `Point.new(1, 2)` instances are `==` because both have `x=1, y=2`. `Point.new(1, 3)` differs in `y`, so `false`.