What's the length of this array in Julia?


#1

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?


#2

What do you get?

julia> struct MyObject end

julia> a = MyObject()
MyObject()

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

julia> length(b)
1