On Thursday, June 16, 2016 at 11:32:25 AM UTC-4, Yichao Yu wrote:
>
> On Thu, Jun 16, 2016 at 11:25 AM, Islam Badreldin 
> <[email protected] <javascript:>> wrote: 
> > Hi 
> > 
> > Is there an easy way to initialize an array of arrays in one statement? 
> I 
> > tried the following 
>
> julia> Any[Float64[1, 2, 3], Float64[4, 5]] 
> 2-element Array{Any,1}: 
>  [1.0,2.0,3.0] 
>  [4.0,5.0] 
>

Great! I used to think that `,` and `;` are interchangeable. Now I see the 
difference!


>
> > 
> >> Any[ Float64[1,2,3]; Float64[4, 5] ] 
> > 5-element Array{Any,1}: 
> >  1.0 
> >  2.0 
> >  3.0 
> >  4.0 
> >  5.0 
> > 
> >> Any[ Float64[1,2,3] Float64[4, 5] ] 
> > ERROR: ArgumentError: number of rows of each array must match (got 
> (3,2)) 
> >  in typed_hcat at abstractarray.jl:772 
> > 
> > 
> > However, what I want to have is (achieved using `push!` in multiple 
> > statements) 
> > 
> > 2-element Array{Any,1}: 
> >  [1.0,2.0,3.0] 
> >  [4.0,5.0] 
> > 
> > Thanks, 
> > Islam 
> > 
>

  -Islam 

Reply via email to