The answer above works if you want a special object for this operation. However, this can be done just using Julia’s native indexing rules with no special objects:
Does the remainder of your code not work for a Matrix in that position? There’s a good chance it will. If not, then you’ll need to write things differently or use the suggested RowIndex object from the earlier answer.
Akin to the RowIndex object above, but without defining or building it specifically, you could use this function:
getrows(x::AbstractVector,rows) = x[rows]
getrows(x::AbstractMatrix,rows) = x[rows,:]
# can write for higher dimensional arrays if needed
# or can write a single definition that works for any number of dimensions, which looks much like the `getindex` function for `RowIndex` defined above
In terms of already available functions, there is also selectdim(v, 1, idxs), which will select entries of the array where the first index varies within idxs. In your example,
This returns a view of the original array rather than copying the data, not sure which is best for your use case (you can always call copy on the output to get a copy of the data).