For the n-dimensional array, I can do it separately

```
A[:, 1] # for 2D
A[:, :, 1] # for 3D
A[:, :, :, 1] # for 4D
```

but how can I do it generally if n is not known in advance? i.e. the number of colons is unknown.

For the n-dimensional array, I can do it separately

```
A[:, 1] # for 2D
A[:, :, 1] # for 3D
A[:, :, :, 1] # for 4D
```

but how can I do it generally if n is not known in advance? i.e. the number of colons is unknown.

Ah, thanks! Follow your suggestions, I also come up with another solution

```
A[fill(:, ndimis(A)-1)..., 1]
```