Skip to content

Instantly share code, notes, and snippets.

@renaudcerrato
Last active February 8, 2019 08:33
Show Gist options
  • Save renaudcerrato/45fd0f7af65e1b2f11f0a70a98873e72 to your computer and use it in GitHub Desktop.
Save renaudcerrato/45fd0f7af65e1b2f11f0a70a98873e72 to your computer and use it in GitHub Desktop.
Kotlin vararg
fun hello(vararg values: String) {
for(value in values) println("Hello $value!")
}
hello("Kotlin", "Java", "Groovy")
// calls using the spread operator
val names = arrayOf("Java", "Groovy")
hello(*names)
hello("Kotlin", *names)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment