From c836ae78bb3da07878dcc37a44c4e07464cab90a Mon Sep 17 00:00:00 2001 From: josh11b Date: Thu, 3 Jun 2021 07:56:48 -0700 Subject: [PATCH] `for` uses `in` instead of `:`, and implement #542. (#563) * `for` uses `in` instead of `:`, and implement #542. --- docs/design/README.md | 4 ++-- docs/design/control_flow/loops.md | 10 +++++----- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/docs/design/README.md b/docs/design/README.md index 21c877929224..ac8133f6b5be 100644 --- a/docs/design/README.md +++ b/docs/design/README.md @@ -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); } ``` @@ -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; diff --git a/docs/design/control_flow/loops.md b/docs/design/control_flow/loops.md index fb663ca8b78c..2139a463c2f6 100644 --- a/docs/design/control_flow/loops.md +++ b/docs/design/control_flow/loops.md @@ -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; @@ -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); } ``` @@ -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; @@ -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; }