1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

doc: group for/in forms (#8721)

This commit is contained in:
Nick Treleaven 2021-02-13 14:53:02 +00:00 committed by GitHub
parent 374739b804
commit f23ffb8322
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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'