2 ms·
The person's birthday is immutable and can't change. The age isn't a mutable property -- it depends on what time we're comparing their birthday to. So it should
by gumballhead 9y ago
The person's birthday is immutable and can't change. The age isn't a mutable property -- it depends on what time we're comparing their birthday to. So it should be computed by a function as he himself says.
The val not being immutable problem is more about declaring something like a list as a val (or final in Java), and being free to modify the elements within the collection anyway so long as the reference to the collection isn't reassigned.
kotlin does have immutable versions of collections in its standard library. It's just not a language feature.