Skip to content

Instantly share code, notes, and snippets.

@parzibyte
Created July 18, 2019 17:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save parzibyte/55244d9208c125f29caead64f5a16fc0 to your computer and use it in GitHub Desktop.
Save parzibyte/55244d9208c125f29caead64f5a16fc0 to your computer and use it in GitHub Desktop.
Variadic and required args in Kotlin function https://parzibyte.me/blog
fun saludarAmigos(nombre: String, vararg nombreAmigos: String){
for (nombreDeAmigo in nombreAmigos){
println("$nombre saluda a $nombreDeAmigo")
}
}
saludarAmigos("Luis", "Pedro", "José", "Raúl", "Ignacio")
/*
Salida:
Luis saluda a Pedro
Luis saluda a José
Luis saluda a Raúl
Luis saluda a Ignacio
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment