In Kotlin, every type has let() and apply() extension functions. These are two simple, but helpful, tools to make your code more fluent and expressive.
Using let() and apply()
Using let()
The let() function simply accepts a lambda expression that maps the invoked object T to another object R. It is similar to how RxJava offers the to() operator, but it applies to any type T and not just Observable/Flowable. For example, we can call let() on a String value that has been lowercased and then immediately do any arbitrary transformation on it, such as concatenating its reversed() value to it. Take a look at this operation (the ch12_17.kt example):
fun main(args: Array<String>) {
val str = "GAMMA"
val lowerCaseWithReversed...