Proposal: deep copy syntax support on language level

Yeah but what if I want to clone address only, what do I do? I think that a pair of () for everything before the element to be cloned should block the look for classes

You mean, extract “address” value and clone it, I suggest? If so, it is useful operation. I think, my original suggestion needs to be corrected.

Let Scala clones the value, after which goes “.{” first time. This way, if we write

person.address.{street = "My Street"}

it copies “address” field, but

person.{address.street = "My Street"}

copies “person”.

Inner braces doesn’t change source of copy, and need just to write shorter.

person.{address.street.{name = "My Street", length = 120}}

instead of

person.{address.street.name = "My Street", address.street.length = 120}}

1 Like