data = [ ... long array of numbers ... ]
dims = [1024,256,128] # (for example)

I want to reshape the data and ideally I would like to do this:

reshape(data,dims)

The problem I have is that reshape() wants the dimensions as a tuple and dims is an array (note that dims is unknown at the start of the program). So I have to reshape() to allow me to use an array, or convert the array into a tuple. For example, I could do this:

reshape(data,ntuple(j -> dims[j],length(dims)))

Technically this works. But I imagine that there has to be a cleaner way to reshape an array. I cannot imagine that anyone who designed Julia intended for people to run this just to reshape an array. So Iâ€™m wondering if there is an alternate recommended way to do what I want to do.

BTW the reason reshape wants a tuple while e.g. sum accepts a vector is that the length of dims is then part of the type, so that the type of the output array (e.g. Array{Int,3} for your dims) can be determined from the type of the inputs.

Itâ€™s called splatting. Here, it basically â€śunpacksâ€ť the array so that instead of tuple([1, 2, 3]) you have tuple(1, 2, 3) which gives the desired result: (1, 2, 3).
You can do the same if you have a function that takes multiple arguments but you have an array/tuple/named tuple with them in it: f(a, b, c) = a * b + c and then f((1.0, 4.0, 5.3)...)