```
v1 = rand(5);
size(v1) # returns (5,)
size(v1, 1) = 5 # fine
size(v1, 2) = 1 # ?
size(v1, 3) = 1 # ??
...
size(v1,100) = 1 # ? ... ?
```

I think I would have expected size(v1, k) for k > 1 to be 0, not 1. Is this intended behavior? Perhaps it has the potential to mislead. Is there some other design consideration I’m ignoring? The problem arose for me because I did the following:

```
l, w = size(v1) # I expected (1,0)
ERROR: BoundsError: attempt to access (5,)
at index [2]
```

I’d justify this by saying that the number of elements in an array `A`

should always be `prod(size(A))`

– as soon as `size(A, i)`

returns `0`

for some `i`

you’d get an empty array.

Your original problem should be written as

```
l, w = size(v1, 1, 2)
```

which is explicit about the dimensions you care about.

1 Like

That is indeed a good reason. Thanks. It’s a little weird to get non-zero sizes for other dimensions in an empty array! But I see your larger point.

```
size([])
(0,)
size([], 1, 2,3)
(0,1,1)
```

Your suggestion is what I ended up doing.

Thanks for your reply!