This is going to be an easy one, because it’s probably about pointing me to the right place in the docs: My MWE
struct Index
i::Int64
end
Base.getindex(A::AbstractArray,i::Index) = A[i.i]
index = [Index(1),Index(3)]
A = [1.,2.,3.,4.]
@show A[index[2]]
@show A[index]
results in
A[index[2]] = 3.0
ERROR: ArgumentError: unable to check bounds for indices of type Index
So accessing array A
with an Index
works, but not with a Vector
of Index
. I do not understand why there should be a bound checking issue. Checking what? Is it about the bounds of A
(why did scalar indexing work?) or of index
(index
is a plain old Vector
, surely, the first index is 1
)?
Confusion achieved!