A past puzzle — fully playable. 4 attempts, hints on wrong guesses.
stdle-153.rb
1Point=Data.define(:x,:y)
2p1=Point.new(x:1,y:2)
3p2=p1.with(y:99)
4putsp1.inspect
5putsp2.inspect
6putsp1.equal?(p2)
Classes
Answer & explanation
Console output
#<data Point x=1, y=2>
#<data Point x=1, y=99>
false
Why
`Data#with` (Ruby 3.2+) returns a new instance with specified attributes overridden. `p1` is unchanged (`x=1, y=2`); `p2` is a new object with `y=99`. `equal?` tests object identity. They are different objects, so `false`.