Wouldn’t it be neat if this was how assignment worked by default?
Numbers already work this way:
x = 5 y = x y += 1 // changes y, not x
Why not maps too?
x = {"a": 1} y = x y["a"] = 2 // changes y, not x
That last line would be short for y = y.update("a", 2), just like y += 1 is short for y = y + 1.
y = y.update("a", 2)
y += 1
y = y + 1
Wouldn’t it be neat if this was how assignment worked by default?
Numbers already work this way:
Why not maps too?
That last line would be short for
y = y.update("a", 2)
, just likey += 1
is short fory = y + 1
.