Post

I love Kotlin but please don't abuse its features. I regularly see code like in the first function when you can instead write a simple if statement: it's shorter, easier to read, and doesn't allocate an object! Thankfully both functions compile to the same assembly when R8 is turned on.

My own pet peeve is when folks use `?.let {} ?:` instead of if/else when checking null It's less readable, and more error prone (because if "doThing()" accidentally returns null, then you end up running the ?: branch, which often is not what you actually want.

A lot of developers misinterpret and think this should be used everywhere. Not sure if this was the intention from JetBrains.

0 reposts2 likes

No replies yet.