Skip to content

let's you use the .let in Kotlin on multiple vars

Notifications You must be signed in to change notification settings

droididan/MultipleLet

Repository files navigation

MultipleLet

let operation in Kotlin takes an object and returns the result in a lambda expression where the it is the value. .let?. also can be used to check nullablity, so if the object is null the block will not run.

like so:

fun main(args: Array<String>) {
    var str = "Hello Kotlin"
    str?.let { println("$it!!") }
    println(str)

}

but what if we want to run .let block on multipule variables? or a collection of items?

multipleLet will let you check up to 5 variables

multipleLet(token, name) { token, name ->
            print("do something with token: $token  name: $name")
}

About

let's you use the .let in Kotlin on multiple vars

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages