fix: 同步官方的错误勘正 (#1212)

Co-authored-by: lanbangjue <lanbangjue@taqu.cn>
This commit is contained in:
VaJoy Lan
2022-12-09 21:43:46 +08:00
committed by GitHub
parent 8f3b7b5b23
commit 4dc673e444

View File

@ -70,9 +70,9 @@ show(photo)
```swift ```swift
let firstPhoto = await listPhotos(inGallery: "Summer Vacation")[0] let firstPhoto = await listPhotos(inGallery: "Summer Vacation")[0]
add(firstPhoto toGallery: "Road Trip") add(firstPhoto, toGallery: "Road Trip")
//此时firstPhoto暂时地同时存在于两个画廊中 //此时firstPhoto暂时地同时存在于两个画廊中
remove(firstPhoto fromGallery: "Summer Vacation") remove(firstPhoto, fromGallery: "Summer Vacation")
``` ```
其它代码不能在 `add(_:toGallery:)``remove(_:fromGallery:)` 两个方法之间运行。在此期间,第一张图片同时存在于两个图库,暂时打破了应用程序的一个不变量。为了更明确地表示这段代码不能加入 `await` 标记,你可以将这段代码重构为一个同步函数: 其它代码不能在 `add(_:toGallery:)``remove(_:fromGallery:)` 两个方法之间运行。在此期间,第一张图片同时存在于两个图库,暂时打破了应用程序的一个不变量。为了更明确地表示这段代码不能加入 `await` 标记,你可以将这段代码重构为一个同步函数: