Skip to content

Commit be78f8b

Browse files
committed
Fix sum(::AbstractArray{Bool}; dims)
1 parent b8a686b commit be78f8b

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

base/reduce.jl

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -523,9 +523,8 @@ julia> sum(1:20)
523523
```
524524
"""
525525
sum(a; kw...) = sum(identity, a; kw...)
526-
sum(a::AbstractArray{Bool}; kw...) = count(a)
527-
# Note: It is OK to ignore `init` to `sum(::AbstractArray{Bool})`
528-
# because it is unspecified if the value of `init` is used or not.
526+
sum(a::AbstractArray{Bool}; init = nothing, kw...) =
527+
init === nothing ? count(a; kw...) : reduce(add_sum, a; init = init, kw...)
529528

530529
## prod
531530
"""

0 commit comments

Comments
 (0)