From a6622014688a07e18f9c3ff7924c6d872a3a2e9a Mon Sep 17 00:00:00 2001 From: sunorry Date: Fri, 25 Sep 2015 22:41:57 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B02.0=E6=94=B9=E5=8A=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- source/chapter2/01_The_Basics.md | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/source/chapter2/01_The_Basics.md b/source/chapter2/01_The_Basics.md index c4f7d6f6..0a21b78b 100755 --- a/source/chapter2/01_The_Basics.md +++ b/source/chapter2/01_The_Basics.md @@ -638,12 +638,13 @@ if let actualNumber = Int(possibleNumber) { 你可以在可选绑定中使用常量和变量。如果你想在`if`语句的第一个分支中操作`actualNumber`的值,你可以改成`if var actualNumber`,这样可选类型包含的值就会被赋给一个变量而非常量。 -多个可选绑定可以用逗号分隔,作为一列表达式出现在一个`if`语句中。 +你可以包含多个可选绑定在`if`语句中,并使用`where`子句做布尔值判断。 ```swift -if let constantName = someOptional, anotherConstantName = someOtherOptional { - statements +if let firstNumber = Int("4"), secondNumber = Int("42") where firstNumber < secondNumber { + print("\(firstNumber) < \(secondNumber)") } +// prints "4 < 42" ```