Task

Demonstrate any means your language has to prevent the modification of values, or to create objects that cannot be modified after they have been created.




class A {
    construct new(f) {
        _f  = f  // sets field _f to the argument f
    }
 
    // getter property to allow access to _f
    f { _f }
 
    // setter property to allow _f to be mutated
    f=(other) { _f = other }
}
 
var a = A.new(6)
System.print(a.f)
a.f = 8
System.print(a.f)