* Update 09_Structures_And_Classes.md

驼峰

* Update 17_Error_Handling.md

病句
This commit is contained in:
Johnson
2019-07-24 12:31:38 +08:00
committed by Jie Liang
parent ebda86cd05
commit b7a8566a0f
2 changed files with 2 additions and 2 deletions

View File

@ -114,7 +114,7 @@ func buyFavoriteSnack(person: String, vendingMachine: VendingMachine) throws {
}
```
上例中,`buyFavoriteSnack(person:vendingMachine:)` 函数会查找某人最喜欢的零食,并通过调用 `vend(itemNamed:)` 方法来尝试为他们购买。因为 `vend(itemNamed:)` 方法能抛出错误,所以在调用它时候在它前面加了 `try` 关键字。
上例中,`buyFavoriteSnack(person:vendingMachine:)` 函数会查找某人最喜欢的零食,并通过调用 `vend(itemNamed:)` 方法来尝试为他们购买。因为 `vend(itemNamed:)` 方法能抛出错误,所以在调用它时候在它前面加了 `try` 关键字。
`throwing` 构造器能像 `throwing` 函数一样传递错误。例如下面代码中的 `PurchasedSnack` 构造器在构造过程中调用了 throwing 函数,并且通过传递到它的调用者来处理这些错误。