summaryrefslogtreecommitdiffhomepage
path: root/es-es/swift-es.html.markdown
diff options
context:
space:
mode:
authorDmitrii Kuznetsov <torgeek@gmail.com>2021-02-22 18:42:33 +0300
committerDmitrii Kuznetsov <torgeek@gmail.com>2021-02-22 18:42:33 +0300
commite09fefaa3e78c645c720c86391e3f96d257be8a9 (patch)
tree0ff8b235e3e707125e2b11d5268ad085832355cb /es-es/swift-es.html.markdown
parentf4c740839d78f797e9cbcfa1eb0483ac0ea45501 (diff)
parentbc8bd2646f068cfb402850f7c0f9b1dbfe81e5a0 (diff)
Merge branch 'master' of https://github.com/torgeek/learnxinyminutes-docs
Diffstat (limited to 'es-es/swift-es.html.markdown')
-rw-r--r--es-es/swift-es.html.markdown30
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"