Although the scope functions are a way of making the code more concise, avoid overusing them: it can decrease your code readability and lead to errors. Avoid nesting scope functions and be careful when chaining them: it’s easy to get confused about the current context object and the value of
this
or
it
.
👍 1
👍🏻 1
k
K Merle
07/08/2022, 1:43 PM
In my experience, it tends to decrease the readability of a code.
K Merle
07/08/2022, 1:44 PM
Usually I'll use just one, and if I need more I might actually add to readability with a variable names. e.g.
Copy code
val something = x?.let{}
val somethingElse = something.apply{}
...