Created
July 18, 2019 17:57
-
-
Save parzibyte/55244d9208c125f29caead64f5a16fc0 to your computer and use it in GitHub Desktop.
Variadic and required args in Kotlin function https://parzibyte.me/blog
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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