Skip to content

Commit

Permalink
for uses in instead of :, and implement #542. (#563)
Browse files Browse the repository at this point in the history
* `for` uses `in` instead of `:`, and implement #542.
  • Loading branch information
josh11b authored Jun 3, 2021
1 parent c51a4b6 commit 8b57b9f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions docs/design/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,7 @@ Print("Done!");
example, this prints all names in `names`:

```carbon
for (var name: String : names) {
for (var name: String in names) {
Print(name);
}
```
Expand All @@ -426,7 +426,7 @@ resume at the end of the loop's scope. For example, this processes steps until a
manual step is hit (if no manual step is hit, all steps are processed):

```carbon
for (var step: Step : steps) {
for (var step: Step in steps) {
if (step.IsManual()) {
Print("Reached manual step!");
break;
Expand Down
10 changes: 5 additions & 5 deletions docs/design/control_flow/loops.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
example, this prints `0`, `1`, `2`, then `Done!`:

```carbon
var Int x = 0;
var x: Int = 0;
while (x < 3) {
Print(x);
++x;
Expand All @@ -40,7 +40,7 @@ Print("Done!");
example, this prints all names in `names`:

```carbon
for (var String name : names) {
for (var name: String in names) {
Print(name);
}
```
Expand All @@ -56,7 +56,7 @@ resume at the end of the loop's scope. For example, this processes steps until a
manual step is hit (if no manual step is hit, all steps are processed):

```carbon
for (var Step step : steps) {
for (var step: Step in steps) {
if (step.IsManual()) {
Print("Reached manual step!");
break;
Expand All @@ -75,9 +75,9 @@ example, this prints all non-empty lines of a file, using `continue` to skip
empty lines:

```carbon
File f = OpenFile(path);
var f: File = OpenFile(path);
while (!f.EOF()) {
String line = f.ReadLine();
var line: String = f.ReadLine();
if (line.IsEmpty()) {
continue;
}
Expand Down

0 comments on commit 8b57b9f

Please sign in to comment.