Skip to content

Commit

Permalink
updated Doc string in Base.Generator (#35261)
Browse files Browse the repository at this point in the history
  • Loading branch information
KristofferC committed Oct 31, 2023
1 parent 85ed34c commit a9509be
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions base/generator.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,26 @@
Given a function `f` and an iterator `iter`, construct an iterator that yields
the values of `f` applied to the elements of `iter`.
The syntax for constructing an instance of this type is `f(x) for x in iter [if cond(x)::Bool] `.
The `[if cond(x)::Bool]` expression is optional and acts as a "guard", effectively
filtering out values where the condition is false.
The syntax `f(x) for x in iter` is syntax for constructing an instance of this
type.
```jldoctest
julia> g = (abs2(x) for x in 1:5 if x != 3);
julia> g = (abs2(x) for x in 1:5);
julia> for x in g
println(x)
end
1
4
9
16
25
julia> collect(g)
4-element Vector{Int64}:
5-element Vector{Int64}:
1
4
9
16
25
```
Expand Down

0 comments on commit a9509be

Please sign in to comment.