Enforced immutability: Difference between revisions
m
→{{header|Wren}}: Changed to Wren S/H
imported>Acediast m (→{{header|COBOL}}: Indentation.) |
m (→{{header|Wren}}: Changed to Wren S/H) |
||
Line 1,527:
Note though that if fields are reference types (lists, maps, user-defined classes etc.) even a 'getter' method may enable their internal state to be mutated unless you copy them first.
<syntaxhighlight lang="
construct new(f) {
_f = f // sets field _f to the argument f
Line 1,552:
{{libheader|Wren-trait}}
Since the above entry was written, a ''Const'' class has been added to ''Wren-trait'' which simulates constants to some extent though the values used need themselves to be immutable for this to be water-tight.
<syntaxhighlight lang="
Const["six"] = 6
|