Question about indexing into an array of arrays

Still learning about how best to use julia. This is probably more of a curious thing I noticed than anything else.

If I create an array like so:

a = [1, 2], [3, 4]]

Both of the following return what I would expect:

a[1]
a[1, 1, 1]

Why does the second line above work? Is there some functionality to being able to do this?

Thanks in advance for the help.

This is the explanation from the official manual:

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

more than N indices may be provided if all the indices beyond the dimensionality of the array are 1 (or more generally are the first and only element of axes(A, d) where d is that particular dimension number). This allows vectors to be indexed like one-column matrices

2 Likes