Fuzion Logo
flang.dev — The Fuzion Language Portal
JavaScript seems to be disabled. Functionality is limited.

Idiom # 90: Read-only outside

See programming-idioms.org:


All fields are automatically write-protected from the outside:

Running Example

Updating the field from inside does work:

Updating the field from outside will cause a compile-time error:

In any case, the preferred way is not to update a field at all, but to create a new instance:

Note that field f is not updated (which would require the set keyword, but there are two fields called f with a non-overlapping scope.