Indexing into multidimensional array

Viewed 98

In Julia, is it possible to index into one array with another? I'm looking for something like this:

a = Array{Int8}(undef, 3, 3, 3)
b = [1,2,3]

a[b] = 12

But so far the only solution I can find is a[b[1], b[2], b[3]] = 12. Is there a cleaner solution?

1 Answers

Here is the clean way of doing it. You use the ... for passing a tuple as function arguments, as well. This is known as splatting.

a[b...]
Related