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
func imprimirMensaje(mensaje: String, veces: Int) { | |
for i in 0..<veces { | |
print("\(i) \(mensaje)") | |
} | |
} | |
imprimirMensaje(mensaje: "Hola baby", veces: 3) | |
// 0 Hola baby | |
// 1 Hola baby | |
// 2 Hola baby |
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
var altura:Int? = 40 // declaro una variable opcional y asigno un valor | |
altura! + 10 // para poder hacer esta suma es necesario extraer (unwrapping) del valor del opcional agregando ! (si no se hace da error) |
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
let edad = 75 | |
switch edad { | |
case 0: | |
print("recien nacido") | |
case 1...12: | |
print("Niño") | |
case 13...18: | |
print("Adolescente") | |
case ...65: // One-Sided Ranges solo en Swift 4. | |
print("Adulto") |