diff options
Diffstat (limited to 'es-es')
-rw-r--r-- | es-es/swift-es.html.markdown | 30 |
1 files changed, 15 insertions, 15 deletions
diff --git a/es-es/swift-es.html.markdown b/es-es/swift-es.html.markdown index 8f63517a..22e3c532 100644 --- a/es-es/swift-es.html.markdown +++ b/es-es/swift-es.html.markdown @@ -446,48 +446,48 @@ if let circle = myEmptyCircle { // Al igual que las clases, pueden contener métodos enum Suit { - case Spades, Hearts, Diamonds, Clubs + case spades, hearts, diamonds, clubs func getIcon() -> String { switch self { - case .Spades: return "♤" - case .Hearts: return "♡" - case .Diamonds: return "♢" - case .Clubs: return "♧" + case .spades: return "♤" + case .hearts: return "♡" + case .diamonds: return "♢" + case .clubs: return "♧" } } } // Los valores de enum permite la sintaxis corta, sin necesidad de poner // el tipo del enum cuando la variable es declarada de manera explícita -var suitValue: Suit = .Hearts +var suitValue: Suit = .hearts // Enums de tipo no-entero requiere asignaciones de valores crudas directas enum BookName: String { - case John = "John" - case Luke = "Luke" + case john = "John" + case luke = "Luke" } -print("Name: \(BookName.John.rawValue)") +print("Name: \(BookName.john.rawValue)") // Enum con valores asociados enum Furniture { // Asociación con Int - case Desk(height: Int) + case desk(height: Int) // Asociación con String e Int - case Chair(String, Int) + case chair(String, Int) func description() -> String { switch self { - case .Desk(let height): + case .desk(let height): return "Desk with \(height) cm" - case .Chair(let brand, let height): + case .chair(let brand, let height): return "Chair of \(brand) with \(height) cm" } } } -var desk: Furniture = .Desk(height: 80) +var desk: Furniture = .desk(height: 80) print(desk.description()) // "Desk with 80 cm" -var chair = Furniture.Chair("Foo", 40) +var chair = Furniture.chair("Foo", 40) print(chair.description()) // "Chair of Foo with 40 cm" |