# Empty Array with nonzero size along some dimension, should they be disallowed?

**URL:** <https://discourse.julialang.org/t/empty-array-with-nonzero-size-along-some-dimension-should-they-be-disallowed/113449>\
**Category:** Internals & Design\
**Tags:** arrays\
**Created:** [April 24, 2024, 1:51pm UTC](https://discourse.julialang.org/t/empty-array-with-nonzero-size-along-some-dimension-should-they-be-disallowed/113449 "2024-04-24T13:51:33Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![nsajko](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/nsajko/32/221187_2.png) [@nsajko](https://discourse.julialang.org/u/nsajko)\
**Post date:** [April 24, 2024, 1:51pm UTC](https://discourse.julialang.org/t/empty-array-with-nonzero-size-along-some-dimension-should-they-be-disallowed/113449/1 "2024-04-24T13:51:33Z")

</div>

On both LTS and nightly we have:

```julia-repl
julia> a = Array{Int}(undef, 0, 1)
0×1 Matrix{Int64}

julia> size(a)
(0, 1)

julia> length(a)
0

```

Is this a bug? I’d actually have expected the construction attempt to throw. Couldn’t find any issues on Github, but I can’t think of a rationale for this behavior.

Alternatively, perhaps it’d be good to normalize the shape, so the result of `Array{Int}(undef, 0, 1)` would be the same as for `Array{Int}(undef, 0, 0)`?

Thoughts?

---

<div class="post-metadata">

**Author:** ![Oscar\_Smith](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/oscar_smith/32/25343_2.png) [@Oscar\_Smith](https://discourse.julialang.org/u/Oscar_Smith)\
**Post date:** [April 24, 2024, 1:54pm UTC](https://discourse.julialang.org/t/empty-array-with-nonzero-size-along-some-dimension-should-they-be-disallowed/113449/2 "2024-04-24T13:54:15Z")

</div>

Why would it throw or change the shape from what the user requested? A 0x1 matrix is perfectly valid.

For a practical example of where the difference between 0x0 and 0x1 matters, `hcat(ones(0,1), ones(1,1))` works, but `hcat(ones(0,0), ones(1,1))` will throw a `DimmensionMismatch.

---

<div class="post-metadata">

**Author:** ![screw\_dog](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/screw_dog/32/48119_2.png) [@screw\_dog](https://discourse.julialang.org/u/screw_dog)\
**Post date:** [April 24, 2024, 1:57pm UTC](https://discourse.julialang.org/t/empty-array-with-nonzero-size-along-some-dimension-should-they-be-disallowed/113449/3 "2024-04-24T13:57:12Z")

</div>

Of possible interest: the [plotting](https://docs.juliaplots.org/latest/#simple-is-beautiful) example “making waves” uses this with:

```julia
...
zs = zeros(0, 40)
...
@gif for i in range(0, stop = 2π, length = n)
    ...
    # add to and show the tracked values over time
    global zs = vcat(zs, z')
    ...
end

```

It’s convenient to initialise the time series data as a 0x40 matrix.
