Or just

[B() for i=1:npop]

Cheers,
   Kevin


On Fri, Jul 25, 2014 at 5:39 PM, John Myles White <[email protected]>
wrote:

> You have to construct the contained objects explicitly. An Array without
> initialization just contains junk memory for all types.
>
> bs = Array(B, npop)
> for i in 1:npop
>   bs[i] = B()
> end
>
>  -- John
>
> On Jul 25, 2014, at 5:36 PM, Ross Boylan <[email protected]> wrote:
>
> > I think I've narrowed down my previous problem.  I have a composite type
> > that has members, some of which are arrays.  How do I initialize those
> > inner arrays properly?  Actually, I have an earlier problem: the objects
> > aren't being created at all.  Here's what I tried (nstep and npop
> > previously set):
> > julia> type B; i::Vector{Int}; end
> >
> > julia> B() = B(zeros(Int, nstep))
> > B (constructor with 3 methods)
> >
> > julia> typeof(B)
> > DataType
> > # but isn't B also the name of a function?
> >
> > julia> bs = Array(B, npop)
> > 4-element Array{B,1}:
> > #undef
> > #undef
> > #undef
> > #undef
> >
> > My hope was that defining what would be a default constructor in C++,
> > name B(), would establish the initial values for the vector elements
> > bs[i].  It didn't.
> >
> > How do I create an Array of B's that are properly initialized?
> >
> > Thanks.
> > Ross Boylan
> >
> > julia 0.3
> >
>
>

Reply via email to