Skip to content

Instantly share code, notes, and snippets.

@arekolek
Forked from cbeyls/KotlinFunctions.md
Last active February 22, 2019 05:20
Show Gist options
  • Save arekolek/91bec2e6ba98446f39d60a7ea2c52f71 to your computer and use it in GitHub Desktop.
Save arekolek/91bec2e6ba98446f39d60a7ea2c52f71 to your computer and use it in GitHub Desktop.
Comparison of Kotlin functions: also, apply, let, run, with

Receiver vs. return value:

Returns block result Returns receiver
Receiver available as it let also
Receiver available as this run apply

How to read the table:

val returnValue = "Receiver".let {
    println("$it is the receiver")
    "Block result"
}
println(returnValue)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment