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 diaDeLaSemana = DiasSemana.Lunes |
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
diaDeLaSemana = .Miercoles | |
diaDeLaSemana = .Domingo |
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
switch diaDeLaSemana { | |
case .Lunes: | |
print("es lunes") | |
case .Martes: | |
print("es martes") | |
case .Miercoles: | |
print("es miércoles") | |
case .Jueves: | |
print("es jueves") | |
case .Viernes: |
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
switch diaDeLaSemana { | |
case .Martes: | |
print("es martes") | |
default: | |
print("no es martes") | |
} |
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
enum Monedas: String { | |
case DolarAmericano = "USD" | |
case PesoCubano = "CUP" | |
case LibraEsterlina = "GBP" | |
case Yen = "JPY" | |
} |
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
// valores raw implícitos desde 0 | |
enum Monedas: Int { | |
case DolarAmericano | |
case PesoCubano | |
case LibraEsterlina | |
case Yen | |
} | |
let dolar = Monedas.DolarAmericano.rawValue | |
let peso = Monedas.PesoCubano.rawValue |
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
// valores raw implícitos desde un valor explícitamente proporcionado | |
enum Monedas: Int { | |
case DolarAmericano = 1 | |
case PesoCubano | |
case LibraEsterlina | |
case Yen | |
} | |
let dolar = Monedas.DolarAmericano.rawValue | |
let peso = Monedas.PesoCubano.rawValue |
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
// valores raw implícitos de tipo String | |
enum Monedas: String { | |
case DolarAmericano | |
case PesoCubano | |
case LibraEsterlina | |
case Yen | |
} | |
let peso = Monedas.PesoCubano.rawValue |
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
// inicialización usando el valor raw | |
enum Monedas: Int { | |
case DolarAmericano | |
case PesoCubano | |
case LibraEsterlina | |
case Yen | |
} | |
let moneda = Monedas(rawValue: 3) |
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
// estructura que implementa dos protocolos | |
struct UnaEstructura: UnProtocolo, OtroProtocolo { | |
// aquí va la definición | |
} |