[15th December 2024] Interesting Things I Learnt This Week
1. Why you should never use !! in Kotlin - Using double-bang operator(!!) is a bad practice; multiple alternatives cover every other possible case. Using it is a hack and a shortcut that will backfire while not saving you much time at the time of writing using it. You shouldn’t use it unless you're writing a short personal script. My Take : The double-bang operator (!!) which throws null pointer exception in Kotlin might very well be considered " Billion Dollar Mistake ." While it offers a concise way to assert that a variable is not null, I believe it's preferable to have slightly more verbose code that explicitly handles nullability and avoids potential runtime exceptions. Null pointer exceptions have plagued programmers for decades, and introducing a feature that can easily lead to them seems counterproductive. I'm uncertain whether all Kotlin linters currently check for excessive or inappropriate use of the !! operator, but if yours don't, I strongly re...