On Thu, Jun 16, 2016 at 11:58 AM, Islam Badreldin
<[email protected]> wrote:
>
>
> 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]> 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!
They never was for typed ones i.e. `T[...]` instead of `[...]` (on
0.4+ at least). They were the same on 0.4 for untyped one but the `,`
version is deprecated and is flip to the new meaning on 0.5 now.
```
julia> [Float64[1, 2, 3], Float64[4, 5]]
2-element Array{Array{Float64,1},1}:
[1.0,2.0,3.0]
[4.0,5.0]
```
>
>>
>>
>> >
>> >> 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