In Kotlin, every type has a let() and apply() extension function. These are two simple but helpful tools to make your code more fluent and expressive.
Using let() and apply()
Using let()
let() simply accepts a lambda 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 Observables/Flowables. For example, we can call let() on a string that has been lowercased and then immediately do any arbitrary transformation on it, such as concatenating its reversed() string to it. Take a look at this operation:
fun main(args: Array<String>) {
val str = "GAMMA"
val lowerCaseWithReversed = str.toLowerCase().let...