Member-only story
Noisy Code 🗣 With Kotlin Scopes
Scopes make your code more readable? think again

You are going to encounter these scope functions namely let, run, apply, also, with
in every Kotlin codebase, along with all the mischievous ways developers exploit their usage from the way they were intended for. Let see how popular opinion on those ends up just as a code noise.
Don’t miss out on the course on Generative AI using Kotlin, Jetpack Compose, Langchain4j, and Ollama. You will learn hands-on by building 6 AI apps. Join now for lifetime access, but hurry — prices increase after July 1st!
Featured On
Don’t miss out on the course on Generative AI using Kotlin, Jetpack Compose, Langchain4j, and Ollama. You will learn hands-on by building 6 AI apps. Join now for lifetime access, but hurry — prices increase after July 1st!
Let me out! ⛓
Popular opinion → let
is treated as a native way to do null checks on the variables.
Please don’t do that even if using `let` feels functionally beautiful but
- You will end up creating another reference called
it
in the same scope which is less descriptive - To fix that you will definitely try to provide an explicit parameter for lambda example
imageFile?.let{ image →
, - but it creates a load of finding another name for the same variable (naming things are hard)
- Now other devs can refer to image files in the scope with two names…