Skip to content

Commit 5a292a8

Browse files
Updated collections.md: changed julia to jldoctest without modifying code
1 parent 04922e7 commit 5a292a8

File tree

1 file changed

+19
-11
lines changed

1 file changed

+19
-11
lines changed

doc/src/base/collections.md

+19-11
Original file line numberDiff line numberDiff line change
@@ -5,21 +5,29 @@
55
Sequential iteration is implemented by the [`iterate`](@ref) function.
66
The general `for` loop:
77

8-
```julia
9-
for i in iter # or "for i = iter"
10-
# body
11-
end
8+
```jldoctest
9+
julia> iter = 1:3
10+
1:3
11+
12+
julia> for i in iter # or "for i = iter"
13+
# body
14+
end
1215
```
1316

1417
is translated into:
1518

16-
```julia
17-
next = iterate(iter)
18-
while next !== nothing
19-
(i, state) = next
20-
# body
21-
next = iterate(iter, state)
22-
end
19+
```jldoctest
20+
julia> iter = 1:3
21+
1:3
22+
23+
julia> next = iterate(iter)
24+
(1,1)
25+
26+
julia> while next !== nothing
27+
(i, state) = next
28+
# body
29+
next = iterate(iter, state)
30+
end
2331
```
2432

2533
The `state` object may be anything, and should be chosen appropriately for each iterable type.

0 commit comments

Comments
 (0)