summaryrefslogtreecommitdiffhomepage
path: root/pt-pt
diff options
context:
space:
mode:
authorAndre Polykanine A.K.A. Menelion Elensúlë <andre@oire.org>2017-10-09 23:03:33 +0300
committerGitHub <noreply@github.com>2017-10-09 23:03:33 +0300
commit33acac42aeb1a5b4f5a00fc5e68b8305861a5ca9 (patch)
tree42a1aa7c873816b45d5676b8ac91c18d2c34e828 /pt-pt
parent6d2bd246ba44807605716be7efa2710a6da6b50e (diff)
parente8ee66c854b8833fcb0fd76b5e9ace6ae8379397 (diff)
Merge pull request #2899 from damian-rzeszot/swift-style-guidelines
[swift/many] Style guidelines
Diffstat (limited to 'pt-pt')
-rw-r--r--pt-pt/swift-pt.html.markdown32
1 files changed, 16 insertions, 16 deletions
diff --git a/pt-pt/swift-pt.html.markdown b/pt-pt/swift-pt.html.markdown
index 9462ee1c..6b263942 100644
--- a/pt-pt/swift-pt.html.markdown
+++ b/pt-pt/swift-pt.html.markdown
@@ -445,49 +445,49 @@ if let circle = myEmptyCircle {
// Enums pode opcionalmente ser um tipo especifico ou não.
// Enums podem conter métodos tal como as classes.
-enum Suit {
- case Spades, Hearts, Diamonds, Clubs
+enum suit {
+ 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 "♧"
}
}
}
// Os valores de Enum permitem syntax reduzida, não é preciso escrever o tipo do enum
// quando a variável é explicitamente definida.
-var suitValue: Suit = .Hearts
+var suitValue: Suit = .hearts
// Enums que não sejam inteiros obrigam a atribuições valor bruto (raw value) diretas
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 com valores associados
enum Furniture {
// Associar com um inteiro (Int)
- case Desk(height: Int)
+ case desk(height: Int)
// Associar com uma String e um 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"