4 ms·
'val' does not make something immutable. It makes it read only. That's very different. You can still call a mutating method of the val entity.
by ragnese 7y ago
'val' does not make something immutable. It makes it read only. That's very different. You can still call a mutating method of the val entity.
- tdelev 7y agoFor sure, declaring something as `val someReferenceOfMutableObject` will not make the object itself immutable, only the reference. The case I had in mind was when creating class with only `val` fields, and that would certainly make that class immutable.