From 9b302e76cb6a11949fcad586a35067d55ef43b58 Mon Sep 17 00:00:00 2001 From: Zhou Fang Date: Mon, 21 Jun 2021 23:39:22 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=96=B0=E5=A2=9E=E5=AF=B9=20for-in=20?= =?UTF-8?q?=E7=9A=84=E6=8F=8F=E8=BF=B0=20(#1141)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- source/02_language_guide/05_Control_Flow.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/source/02_language_guide/05_Control_Flow.md b/source/02_language_guide/05_Control_Flow.md index c3234b2b..823e3f91 100755 --- a/source/02_language_guide/05_Control_Flow.md +++ b/source/02_language_guide/05_Control_Flow.md @@ -97,6 +97,8 @@ for tickMark in stride(from: 3, through: hours, by: hourInterval) { } ``` +以上示例使用 `for-in` 循环来遍历范围、数组、字典和字符串。你可以用它来遍历任何的集合,包括实现了 [Sequence](https://developer.apple.com/documentation/swift/sequence) 协议的自定义类或集合类型。 + ## While 循环 {#while-loops} `while` 循环会一直运行一段语句直到条件变成 `false`。这类循环适合使用在第一次迭代前,迭代次数未知的情况下。Swift 提供两种 `while` 循环形式: