Apparently `getindex` of a vector accepts more than one index?!

Why doesn’t this throw, given that the array [10, 20] is one-dimensional? I would expect a MethodError.

julia> [10, 20][1, 1, 1]
10

This is documented:

https://docs.julialang.org/en/v1/manual/arrays/#Omitted-and-extra-indices

Probably it wouldn’t hurt to have a short explanation of why that’s convenient. I remember reading discussions about that here.

4 Likes