I’m trying to update value but give this error.
expected mutable assignment target
type Invoice = {
invoice_no:Nat;
};
var InvoiceObj : Invoice = {
invoice_no = 0;
};
InvoiceObj.invoice_no:=10;
How to update this value?
I’m trying to update value but give this error.
expected mutable assignment target
type Invoice = {
invoice_no:Nat;
};
var InvoiceObj : Invoice = {
invoice_no = 0;
};
InvoiceObj.invoice_no:=10;
How to update this value?
Change the type declaration to:
type Invoice = {
var invoice_no:Nat;
};
InvoiceObj := { invoice_no = 10 };
Or change invoice_no
to var invoice_no
like @v1ctor suggested.
I tried but it’s give me this error
type Invoice = {
var invoice_no:Nat;
};
var InvoiceObj : Invoice = {
invoice_no = 0; // Error expected mutable 'var' field total of type Nat but found immutable field (insert 'var'?)
};
If there’s any mutable field, declared with “var”, you have to repeat that when creating a new object:
type SomeType = {
var field: Nat;
};
var obj: SomeType = {
var field = 1234;
};