On Fri, Sep 11, 2015 at 11:39 AM, Alex M <[email protected]> wrote:
> Hello,
> I am learning Julia.
>
> Both are arrays but of different types:
>
> julia> {}
> 0-element Array{Any,1}
>
> julia> []
> 0-element Array{None,1}
>
>
> julia> [] == {}
> true
>
> Now I am trying to push new data :
>
>
> julia> a = []
> julia> b = {}
>
>
> julia> push!(a,"y")
> ERROR: [] cannot grow. Instead, initialize the array with "T[]", where T is
> the desired element type.
> in push! at array.jl:457 (repeats 2 times)
>
>
> But for [] it works:
>
> julia> push!(b,"y")
> 1-element Array{Any,1}:
> "y"
>
>
> Also using {} I can create Dictionary:
>
> julia> {"a" => 3}
> Dict{Any,Any} with 1 entry:
> "a" => 3
>
>
> Now I am very confused.
>
> 1) What is the meaning of { } ? is it a dictionary constructor or an array
> constructor of type Any ?
It was `Any[]` for 0.3. Deprecated for 0.4
> 2) Why can't I push into [ ] ?
Because the type is None. `[]` on 0.4 returns `Array{Any,1}` and that
isn't a problem anymore.
>
> Thank you in advance!