The below code is not good

fun process(stringList: List<String>?, removeString: String): Int? = stringList
?.filterNot { it == removeString }
?.map { it.length }
?.sum()

as it introduces a lots of unnecessary branches. Try create unit test for it, and see if you could easily achieve 100% branch coverage. You’ll understand what I meant. Optionally you could look at the decompile code, and see the longer code generated compare to using let to eliminate the extra ?.

Written by

Passionate about learning, and sharing mobile development and others

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store