Hello,
I’ve been surprised by the return type of the mapping of a type stable function on a couple of static arrays.
Here is a minimal example, first with regular arrays
julia> n = 4;
julia> bool = rand(Bool, n);
julia> pair = [rand(1:n, 2) for i in 1:n];
julia> map(pair) do ci
(&)(bool[ci]...)
end;
julia> typeof(ans)
Array{Bool,1}
Let’s now use static arrays and look at the type of the result:
julia> using StaticArrays
julia> sbool = SVector(bool...);
julia> spair = SVector(pair...);
julia> map(spair) do ci
(&)(sbool[ci]...)
end;
julia> typeof(ans)
StaticArrays.SArray{Tuple{4},Any,1,4}
I was surprised to see the element type on return to be Any
instead of Bool
in this case.
Is this expected? Or am I missing something? I’ve been scratching my head on this one and would be grateful for any feedback!
V.