Hi

Am 2025-05-15 14:14, schrieb Rob Landers:
For example, if you have a Money type, you'd want to be able to ensure it cannot be negative when updating via `with()`. This is super important for ensuring constraints are met during the clone.

That's why the assignments during cloning work exactly like regular property assignments, observing visibility and property hooks.

The only tiny difference is that an “outsider” is able to change a `public(set) readonly` property after a `__clone()` method ran to completion and relied on the property in question not changing on the cloned object after it observed its value. This seems not to be something relevant in practice, because why would the exact value of the property only matter during cloning, but not at any other time?

Best regards
Tim Düsterhus

Reply via email to