Am I doing something wrong? I defined a var in the...
# announcements
s
Am I doing something wrong? I defined a var in the constructor. The var is used by the parent constructor. I can use the value. But when I try to update it, it says val can't be reassigned.. but it isn't a val
t
This is because you are writing a lambda that is passed to the superclass constructor, in the constructor of your class. In this context, the compiler thinks you are referring to the constructor param named
currentState
and not the property of the same name. If you want to reference the property, apply the "Assign to property" suggestion of the IDE to introduce
this
.
s
Ah oki, thanks!