7 ms·
I went from using Java to Kotlin at work, and I hate the “?.” notation. I’m sure it’s nice when used correctly, but it seems that people just use it everywhere
by MichaelNolan 4y ago
I went from using Java to Kotlin at work, and I hate the “?.” notation. I’m sure it’s nice when used correctly, but it seems that people just use it everywhere and now the program went from “When I do x and it crashes” -> “When I do x nothing happens”. It hides errors and makes debugging more difficult.
I love null being apart of the type system, but the safe call operator seems like a huge step backwards.
- grog454 4y ago?. Should generally be rare and can be combined with null coalescence to reduce occurrences: Void func doThing(state : State?) { var idx = state?.idx ?? -1 //No more ?. Needed }
- imtringued 4y agoWhy would people use it everywhere in Kotlin? I thought types weren't nullable by default. Also I don't see the difference between if(a != null) { a.b(); } and a?.b(). They won't result in NPEs either way and I see the former everywhere in Java as well.