Hi Charles,
Array{String} is a type, not an array:
julia> isa(Array{String}, Type)
true
julia> typeof(Array{String})
DataType
See http://docs.julialang.org/en/release-0.3/manual/types/ .
The function Array(eltype, dimensions...) can be used to instantiate an
object of this type, which is the convention in Julia, so IMO you should
just keep using that.
Best,
Tamas
On Thu, Mar 12 2015, Charles Novaes de Santana wrote:
> Dear all,
>
> I was trying to create a vector of strings in Julia and I didn't understand
> why the following ways give me different results.
>
> Everything is fine If I try the following two approaches:
> names = String[];
> push!(names,"word1");
>
> names = Array(String,0);
> push!(names,"word1");
>
> However, I supposed this other way should work too, but it didn't:
> names = Array{String};
> push!(names,"word2");
>
> It gives me the following error: "ERROR: `push!` has no method matching
> push!(::Type{Array{String,N}}, ::ASCIIString)"
>
> Why is String[] and Array(String,0) different from Array{String}?
>
> Thanks for any help!
>
> Best,
>
> Charles
>
> --
> Um axé! :)