Bools in arithmetic operations

For the general question of “why is Bool an Integer, see:

https://github.com/JuliaLang/julia/issues/19168

For your particular case, if you don’t want Bool to be accepted as input in your function, just make it throw an error in such a case:

julia> gety(m, ::Bool) = throw(ArgumentError("Bool not allowed"))
gety (generic function with 1 method)

julia> gety(m, true)
ERROR: ArgumentError: Bool not allowed
Stacktrace:
 [1] gety(::Array{Int64,1}, ::Bool) at .\REPL[1]:1
 [2] top-level scope at REPL[2]:1234:1
6 Likes