Skip to content

Commit 23748ec

Browse files
authored
Use neutral element as init in reduce doctest (#55065)
The documentation of reduce states that init must be the neutral element. However, the provided doctest uses a non-neutral element for init. Fix this by changing the example.
1 parent fc775c5 commit 23748ec

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

base/reduce.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -472,8 +472,8 @@ elements are not reordered if you use an ordered collection.
472472
julia> reduce(*, [2; 3; 4])
473473
24
474474
475-
julia> reduce(*, [2; 3; 4]; init=-1)
476-
-24
475+
julia> reduce(*, Int[]; init=1)
476+
1
477477
```
478478
"""
479479
reduce(op, itr; kw...) = mapreduce(identity, op, itr; kw...)

0 commit comments

Comments
 (0)