swift | fix style guidelines

This commit is contained in:
Damian Rzeszot 2017-10-09 12:03:27 +02:00
parent 9a9e52b54b
commit e8ee66c854
7 changed files with 44 additions and 44 deletions

View File

@ -467,23 +467,23 @@ print("Name: \(BookName.john.rawValue)")
// Enum mit assoziierten Werten
enum Furniture {
// mit Int assoziiert
case Desk(height: Int)
case desk(height: Int)
// mit String und Int assoziiert
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"

View File

@ -471,23 +471,23 @@ 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"

View File

@ -471,23 +471,23 @@ 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"

View File

@ -561,23 +561,23 @@ print("Имя: \(BookName.john.rawValue)")
// Перечисление (enum) со связанными значениями
enum Furniture {
// Связать с типом Int
case Desk(height: Int)
case desk(height: Int)
// Связать с типами String и Int
case Chair(String, Int)
case chair(String, Int)
func description() -> String {
switch self {
case .Desk(let height):
case .desk(let height):
return "Письменный стол высотой \(height) см."
case .Chair(let brand, let height):
case .chair(let brand, let height):
return "Стул марки \(brand) высотой \(height) см."
}
}
}
var desk: Furniture = .Desk(height: 80)
var desk: Furniture = .desk(height: 80)
print(desk.description()) // "Письменный стол высотой 80 см."
var chair = Furniture.Chair("Foo", 40)
var chair = Furniture.chair("Foo", 40)
print(chair.description()) // "Стул марки Foo высотой 40 см."

View File

@ -544,23 +544,23 @@ print("Name: \(BookName.john.rawValue)")
// Enum with associated Values
enum Furniture {
// Associate with Int
case Desk(height: Int)
case desk(height: Int)
// Associate with String and 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"

View File

@ -467,23 +467,23 @@ print("Name: \(KitapAdi.john.rawValue)")
// Değerlerle ilişkilendirilmiş Enum
enum Mobilya {
// Int ile ilişkilendirilmiş
case Masa(yukseklik: Int)
case masa(yukseklik: Int)
// String ve Int ile ilişkilendirilmiş
case Sandalye(String, Int)
case sandalye(String, Int)
func aciklama() -> String {
switch self {
case .Masa(let yukseklik):
case .masa(let yukseklik):
return "Masa boyu \(yukseklik) cm"
case .Sandalye(let marka, let yukseklik):
case .sandalye(let marka, let yukseklik):
return "\(brand) marka sandalyenin boyu \(yukseklik) cm"
}
}
}
var masa: Mobilya = .Masa(yukseklik: 80)
var masa: Mobilya = .masa(yukseklik: 80)
print(masa.aciklama()) // "Masa boyu 80 cm"
var sandalye = Mobilya.Sandalye("Foo", 40)
var sandalye = Mobilya.sandalye("Foo", 40)
print(sandalye.aciklama()) // "Foo marka sandalyenin boyu 40 cm"

View File

@ -469,23 +469,23 @@ print("Name: \(BookName.john.rawValue)")
// 与特定数据类型关联的枚举
enum Furniture {
// 和 Int 型数据关联的枚举记录
case Desk(height: Int)
case desk(height: Int)
// 和 String, Int 关联的枚举记录
case Chair(brand: String, height: Int)
case chair(brand: String, height: 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(brand: "Foo", height: 40)
var chair = Furniture.chair(brand: "Foo", height: 40)
print(chair.description()) // "Chair of Foo with 40 cm"