diff options
author | Andre Polykanine A.K.A. Menelion Elensúlë <andre@oire.org> | 2017-10-09 23:03:33 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-10-09 23:03:33 +0300 |
commit | 33acac42aeb1a5b4f5a00fc5e68b8305861a5ca9 (patch) | |
tree | 42a1aa7c873816b45d5676b8ac91c18d2c34e828 /es-es/swift-es.html.markdown | |
parent | 6d2bd246ba44807605716be7efa2710a6da6b50e (diff) | |
parent | e8ee66c854b8833fcb0fd76b5e9ace6ae8379397 (diff) |
Merge pull request #2899 from damian-rzeszot/swift-style-guidelines
[swift/many] Style guidelines
Diffstat (limited to 'es-es/swift-es.html.markdown')
-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" |