From ff3880f81c78d967f94bb91beabe6e719eecfc57 Mon Sep 17 00:00:00 2001 From: bqlin Date: Mon, 14 Jan 2019 09:47:03 +0800 Subject: [PATCH 1/2] =?UTF-8?q?17=5FError=5FHandling=20=E4=BC=98=E5=8C=96?= =?UTF-8?q?=E7=BF=BB=E8=AF=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- source/chapter2/17_Error_Handling.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/chapter2/17_Error_Handling.md b/source/chapter2/17_Error_Handling.md index eac4ed4e..4efce71f 100755 --- a/source/chapter2/17_Error_Handling.md +++ b/source/chapter2/17_Error_Handling.md @@ -199,7 +199,7 @@ do { ### 将错误转换成可选值 -可以使用 `try?` 通过将错误转换成一个可选值来处理错误。如果在评估 `try?` 表达式时一个错误被抛出,那么表达式的值就是 `nil`。例如,在下面的代码中,`x` 和 `y` 有着相同的数值和等价的含义: +可以使用 `try?` 通过将错误转换成一个可选值来处理错误。如果是在计算 `try?` 表达式时抛出错误,该表达式的结果就为 `nil`。例如,在下面的代码中,`x` 和 `y` 有着相同的数值和等价的含义: ```swift func someThrowingFunction() throws -> Int { From 4081d8d286a46e701cbe28923dd668bc7b10fadc Mon Sep 17 00:00:00 2001 From: bqlin Date: Mon, 14 Jan 2019 09:47:37 +0800 Subject: [PATCH 2/2] =?UTF-8?q?18=5FType=5FCasting=20=E7=A7=BB=E9=99=A4?= =?UTF-8?q?=E5=A4=9A=E4=BD=99=E7=A9=BA=E8=A1=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- source/chapter2/18_Type_Casting.md | 3 --- 1 file changed, 3 deletions(-) diff --git a/source/chapter2/18_Type_Casting.md b/source/chapter2/18_Type_Casting.md index 434e3a5a..6f4210d2 100644 --- a/source/chapter2/18_Type_Casting.md +++ b/source/chapter2/18_Type_Casting.md @@ -200,12 +200,9 @@ for thing in things { > 注意 > > `Any` 类型可以表示所有类型的值,包括可选类型。Swift 会在你用 `Any` 类型来表示一个可选值的时候,给你一个警告。如果你确实想使用 `Any` 类型来承载可选值,你可以使用 `as` 操作符显式转换为 `Any`,如下所示: -> -> ```swift let optionalNumber: Int? = 3 things.append(optionalNumber) // 警告 things.append(optionalNumber as Any) // 没有警告 ``` -