# What's the length of this array in Julia?

**URL:** <https://discourse.julialang.org/t/whats-the-length-of-this-array-in-julia/19718>\
**Category:** General Usage\
**Created:** [January 16, 2019, 7:24pm UTC](https://discourse.julialang.org/t/whats-the-length-of-this-array-in-julia/19718 "2019-01-16T19:24:07Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![bsnyh](https://avatars.discourse-cdn.com/v4/letter/b/ce7236/32.png) [@bsnyh](https://discourse.julialang.org/u/bsnyh)\
**Post date:** [January 16, 2019, 7:24pm UTC](https://discourse.julialang.org/t/whats-the-length-of-this-array-in-julia/19718/1 "2019-01-16T19:24:07Z")

</div>

Suppose myObject is a defined type. The following is a part of my code.

> a=myObject() # calling the default constructor  
> b=[a]  
> println(length(b))

Should’t this give me 1? Because b is an array of only one element, which is a, and which is of type myObject, right?

---

<div class="post-metadata">

**Author:** ![StefanKarpinski](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stefankarpinski/32/24_2.png) [@StefanKarpinski](https://discourse.julialang.org/u/StefanKarpinski)\
**Post date:** [January 16, 2019, 7:25pm UTC](https://discourse.julialang.org/t/whats-the-length-of-this-array-in-julia/19718/2 "2019-01-16T19:25:08Z")

</div>

What do you get?

```julia
julia> struct MyObject end

julia> a = MyObject()
MyObject()

julia> b = [a]
1-element Array{MyObject,1}:
 MyObject()

julia> length(b)
1

```
