I have an object and I’d like to change the value of one of its properties, keeping everything else the same. I assumed this would work:
type Person = {
name: Text;
age: Nat;
};
var mike = {
name = "Mike";
age = 33;
};
mike.age := 34;
I get type error, expected mutable assignment target
. I get the same error when I defining the type like this:
type Person = {
name: Text;
var age: Nat;
};
It must be possible to change object property values after creation, but obviously not the way I’m trying to do it. I’m finding it somewhat difficult to learn simple things like this due to the lack of Motoko tutorials and examples out there.