From 5946afca2ea7a1da97e5d390ee02e264a5b65826 Mon Sep 17 00:00:00 2001 From: futantan Date: Mon, 29 Jun 2015 11:27:13 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E7=A4=BA=E4=BE=8B=E4=BB=A3?= =?UTF-8?q?=E7=A0=81=EF=BC=8Cprintln()=20->=20println()?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- source/chapter2/08_Enumerations.md | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/source/chapter2/08_Enumerations.md b/source/chapter2/08_Enumerations.md index 1484694f..570f1de2 100755 --- a/source/chapter2/08_Enumerations.md +++ b/source/chapter2/08_Enumerations.md @@ -79,13 +79,13 @@ directionToHead = .East directionToHead = .South switch directionToHead { case .North: - println("Lots of planets have a north") + print("Lots of planets have a north") case .South: - println("Watch out for penguins") + print("Watch out for penguins") case .East: - println("Where the sun rises") + print("Where the sun rises") case .West: - println("Where the skies are blue") + print("Where the skies are blue") } // 输出 "Watch out for penguins” ``` @@ -104,9 +104,9 @@ case .West: let somePlanet = Planet.Earth switch somePlanet { case .Earth: - println("Mostly harmless") + print("Mostly harmless") default: - println("Not a safe place for humans") + print("Not a safe place for humans") } // 输出 "Mostly harmless” ``` @@ -164,9 +164,9 @@ productBarcode = .QRCode("ABCDEFGHIJKLMNOP") ```swift switch productBarcode { case .UPCA(let numberSystem, let identifier, let check): - println("UPC-A with value of \(numberSystem), \(identifier), \(check).") + print("UPC-A with value of \(numberSystem), \(identifier), \(check).") case .QRCode(let productCode): - println("QR code with value of \(productCode).") + print("QR code with value of \(productCode).") } // 输出 "QR code with value of ABCDEFGHIJKLMNOP.” ``` @@ -176,9 +176,9 @@ case .QRCode(let productCode): ```swift switch productBarcode { case let .UPCA(numberSystem, identifier, check): - println("UPC-A with value of \(numberSystem), \(identifier), \(check).") + print("UPC-A with value of \(numberSystem), \(identifier), \(check).") case let .QRCode(productCode): - println("QR code with value of \(productCode).") + print("QR code with value of \(productCode).") } // 输出 "QR code with value of ABCDEFGHIJKLMNOP." ``` @@ -237,15 +237,14 @@ let positionToFind = 9 if let somePlanet = Planet(rawValue: positionToFind) { switch somePlanet { case .Earth: - println("Mostly harmless") + print("Mostly harmless") default: - println("Not a safe place for humans") + print("Not a safe place for humans") } } else { - println("There isn't a planet at position \(positionToFind)") + print("There isn't a planet at position \(positionToFind)") } // 输出 "There isn't a planet at position 9 ``` 这个范例使用可选绑定(optional binding),通过原始值`9`试图访问一个行星。`if let somePlanet = Planet(rawValue: 9)`语句获得一个可选`Planet`,如果可选`Planet`可以被获得,把`somePlanet`设置成该可选`Planet`的内容。在这个范例中,无法检索到位置为`9`的行星,所以`else`分支被执行。 -