Style question: When overriding a nullable val pro...
# announcements
m
Style question: When overriding a nullable val property with a null, do you prefer
override val myVal = null
or
override val myVal get() = null
1️⃣ 7
2️⃣ 7
s
I don't see any reason why we'd need to call a function that returns
null
every time, so the first one.
👍 2
d
If the val is overridden again in a subclass you now have two fields, one of which is unused.
s
You call a function in both cases. I guess the difference is having a local variable for storing the null or not which seems a bit pointless
☝️ 1
s
Yeah, I guess that's true.