> type DB
>   Y::Vector{Complex128}
>   W::Vector{Float64}
> end
>
> y = Array(Complex128,100)
> w = Array(Float64,100)
>
> data = Array(DB,100)     # making an array of 100 elements of type DB

This just creates an array of pointers to DB objects but the DB objects
themselves are not created.  Thus if you look at it:

julia> data
100-element Array{DB,1}:
 #undef
 #undef


Note that Array(Complex128,100) doesn't contain undefs as its elements
are isbits types thus not accessed via pointer indirection. (but its
elements are random).

> data[10].Y = 2.0+3.0im   # this results in an getindex error as there is no 
> method to support the assignment. 

So this tries to access an undef object, further it also tries
assigning a scalar to a vector.  You can do for instance:

julia> data[10] = DB(y,w)
DB(Complex{Float64}[6.03421e-316+....

If you want to fill them all, then iteration is the way forward.  Better
get used to iteration, it crops up a lot...

> Can someone advise the correct syntax for making data an array with 100 
> elements of type DB and filling it with vectors instead of iterating 
> through the assignment of the elements?
>
>
>>>  

Reply via email to