harry.singh
03/17/2020, 11:08 PMWhen you're using a smart cast with a property of a class, the property has to be a val and it can't have a custom accessor. Otherwise, it would not be possible to verify that every access to the property would return the same value.Makes sense but one thing that I don't understand is, what does the author mean
property has to be a val and it can't have a custom accessorDoesn't val properties provide only getter methods?
araqnid
03/17/2020, 11:24 PMval someProperty get() = …
= custom accessorharry.singh
03/18/2020, 12:08 AMval someProperty get() = ...
fails to verify that the val was changed?Quy D X Nguyen
03/18/2020, 12:15 AMaraqnid
03/18/2020, 12:21 AMval someProperty: String? get() = if (System.currentTimeMillis % 2 == 0) "hello" else null
- the nullness-or-not is unpredictableharry.singh
03/19/2020, 3:18 PM