You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Now, let's write the mutable version. Notice the keywords 'mutable' placed in front of the field and the method. this.!field = value modifies object in place, much like in any other programming language.
mutableclassPoint{mutablex: Int,y: Int}{mutablefunincrX(): void{// TODO: increment the field 'x' by 1// HINT: 'this.!x = value' sets the field 'x' to 'value'}}
A compilation error is returned regardless of the expression tested with run:
File"playground.sk",line1,characters15-19:
In'Point'sversionofthemember'!='inheritedfrom'Equality'1|mutableclassPoint{mutablex: Int,y: Int}{|^^^^^2|mutablefunincrX(): void{File"tests/runtime/prelude/core/traits/Equality.sk", line 26,characters12-13:
Cannotcallthismethodonareadonlyobject24|25|overridablereadonlyfun!=(other: inst): Bool{26|!(this==other)|^^27|}File"playground.sk",line13,characters7-8:
Tryannotating'=='methodas'readonly'11|extensionclassPointusesEquality,Show{12|// Defining equality for a Point13|fun==(other: this): Bool{|^^14|other.x==this.x&&other.y==this.y
The text was updated successfully, but these errors were encountered:
In tutorial for exercice n°10:
Now, let's write the mutable version. Notice the keywords 'mutable' placed in front of the field and the method. this.!field = value modifies object in place, much like in any other programming language.
A compilation error is returned regardless of the expression tested with run:
The text was updated successfully, but these errors were encountered: