Skip to content

Instantly share code, notes, and snippets.

@parzibyte
Created July 18, 2019 17:36
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/bee82e3d0bab5bbd555ca44f5f2f7ffa to your computer and use it in GitHub Desktop.
Save parzibyte/bee82e3d0bab5bbd555ca44f5f2f7ffa to your computer and use it in GitHub Desktop.
Funciones con argumentos opcionales en Kotlin https://parzibyte.me/blog
// Definir funciones sobrecargadas
fun sumar(numero1: Int, numero2: Int) = numero1 + numero2
fun sumar(numero1: Int, numero2: Int, numero3: Int) = numero1 + numero2 + numero3
// Invocarlas
val resultado = sumar(20, 1)
println("La suma es: $resultado")
val otroResultado = sumar(28, 11, 96)
println("La suma es: $otroResultado")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment