The other part was a bit of a brain fart i should ...
# random
d
The other part was a bit of a brain fart i should have said I make them nullable. Like if a Java class is passing me something it maybe null so Its best to let kotlin know that it maybe null
m
I don't believe it's not the best approach. You should only use nullables when Java code will send you null. If Java code might send you null, but that's a bug, then you can catch it early by making sure your definitions are not nullable. E.g.
onCreate(Bundle)
should have
Bundle?
, because it will always send null on first call to this function. On the other hand
onOptionsItemSelected(MenuItem)
should not have
MenuItem?
because Android framework will never call it with null.
2
d
True. I agree with you, It was bad wording on my part. I tend to only use
?
when I think it can be null.