Skip to content

Instantly share code, notes, and snippets.

@eungju
Last active July 5, 2022 21:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save eungju/9929a51a140f8b52b458219a82e59897 to your computer and use it in GitHub Desktop.
Save eungju/9929a51a140f8b52b458219a82e59897 to your computer and use it in GitHub Desktop.
Kotlin let run apply also

let

inline fun <T, R> T.let(block: (T) -> R): R = block(this)

run

inline fun <T, R> T.run(block: T.() -> R): R = block()

apply

inline fun <T> T.apply(block: T.() -> Unit): T { block(); return this }

also

inline fun <T> T.also(block: (T) -> Unit): T { block(this); return this }

                  리턴값이 리시버인가? block의 리턴값인가?

리시버가 block의 리시버가 되는가? apply run 파라메터가 되는가? also let

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment