From f23ffb83221fbe2693402ca3a99f33b342dd0945 Mon Sep 17 00:00:00 2001 From: Nick Treleaven Date: Sat, 13 Feb 2021 14:53:02 +0000 Subject: [PATCH] doc: group `for`/`in` forms (#8721) --- doc/docs.md | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/doc/docs.md b/doc/docs.md index 2959b6bd9f..d59262159f 100644 --- a/doc/docs.md +++ b/doc/docs.md @@ -1104,7 +1104,12 @@ so both `if` statements above produce the same machine code and no arrays are cr V has only one looping keyword: `for`, with several forms. -#### Array `for` +#### `for`/`in` + +This is the most common form. You can use it with an array, map or +numeric range. + +##### Array `for` ```v numbers := [1, 2, 3, 4, 5] @@ -1134,7 +1139,7 @@ println(numbers) // [1, 2, 3] ``` When an identifier is just a single underscore, it is ignored. -#### Map `for` +##### Map `for` ```v m := map{ @@ -1168,7 +1173,7 @@ for _, value in m { } ``` -#### Range `for` +##### Range `for` ```v // Prints '01234'