Bug/unexpected behavior when extending Base.any with new type

Both your original version or the suggestion to implement Base.any(array::Matrix{<:Real}) are cases of type piracy (see examples). You have modified a function you do not “own” (is not originally defined in the code you’re working on) for a type that you also do not own.

Piracy risks breaking your entire Julia session (and anyone’s who uses your code) in subtle and insidious ways and is strongly discouraged. I recommend using the suggested call to any(==(1), A; dims=2), which is exactly equal to your version but more flexible and not a case of piracy.

6 Likes