Skip to content

Instantly share code, notes, and snippets.

@sahara-ooga
Created November 17, 2019 12:04
Show Gist options
  • Save sahara-ooga/eacecbb658cccb58376aa29c469e0093 to your computer and use it in GitHub Desktop.
Save sahara-ooga/eacecbb658cccb58376aa29c469e0093 to your computer and use it in GitHub Desktop.
スコープ関数の例
fun main() {
val s_let = "hoge".let { it.toUpperCase() }
println(s_let) //=> HOGE
val s_with = with("hoge") { this.toUpperCase() }
println(s_with) //=> HOGE
val s_run = "hoge".run { toUpperCase() }
println(s_run) //=> HOGE
val s_apply = "hoge".apply {
toUpperCase()
}
println(s_apply) //=> hoge
val s_also = "hoge".also { it.toUpperCase() }
println(s_also) //=> hoge
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment