We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 04922e7 commit 15934edCopy full SHA for 15934ed
doc/src/base/collections.md
@@ -5,21 +5,32 @@
5
Sequential iteration is implemented by the [`iterate`](@ref) function.
6
The general `for` loop:
7
8
-```julia
9
-for i in iter # or "for i = iter"
10
- # body
11
-end
+```jldoctest
+julia> for i in 1:3 # or "for i = iter"
+ println(i)
+ end
12
+1
13
+2
14
+3
15
```
16
17
is translated into:
18
19
```julia
-next = iterate(iter)
-while next !== nothing
- (i, state) = next
20
21
- next = iterate(iter, state)
22
+julia> iter = 1:3
+1:3
+
23
+julia> next = iterate(iter)
24
+(1,1)
25
26
+julia> while next !== nothing
27
+ (i, state) = next
28
29
+ next = iterate(iter, state)
30
31
32
33
34
35
36
The `state` object may be anything, and should be chosen appropriately for each iterable type.
0 commit comments