Skip to content

Instantly share code, notes, and snippets.

@gaplo917
Last active January 15, 2017 17:35
Show Gist options
  • Save gaplo917/f687f1ad09988c32fa888179ce33d24a to your computer and use it in GitHub Desktop.
Save gaplo917/f687f1ad09988c32fa888179ce33d24a to your computer and use it in GitHub Desktop.
Kotlin Functional Support 2
val list = listOf(1,2,3,4,5)
// destructing the list
val (a,b,c) = list
println("a = $a, b = $b, c = $c")
// a = 1, b = 2, c = 3
// already include in kotlin std-lib
val head = list.head
val tail = list.tail
println(head) // 1
println(tail) // [2,3,4,5]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment