Why `"hello"^true` is allowed?



Personally, I try not to think too much about this. I am happy with whatever option the core team picks, provided that we don’t keep discussing it. I can appreciate arguments for all sides of this debate, but for me this does not make it into the top 500 issues, and the discussion/importance ratio for this particular issue appears to approach ∞.


To directly address the original question,

Why allow exponentiation with a Boolean?

If you look at what’s actually being called, you’ll find that there isn’t an explicit method for Bool:

julia> @which "hello"^true
^(s::AbstractString, r::Integer) in Base at strings/types.jl:154

The fact that "hello"^true works is actually just a side effect of the fact that Bool <: Integer.