We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 04922e7 commit 5a292a8Copy full SHA for 5a292a8
doc/src/base/collections.md
@@ -5,21 +5,29 @@
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> iter = 1:3
+1:3
+
12
+julia> for i in iter # or "for i = iter"
13
+ # body
14
+ end
15
```
16
17
is translated into:
18
-next = iterate(iter)
-while next !== nothing
19
- (i, state) = next
20
21
- next = iterate(iter, state)
22
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
The `state` object may be anything, and should be chosen appropriately for each iterable type.
0 commit comments