a = [uppercase(key) for key in keys(dict)] # works fine
dict = Dict("a" => 1, "b" => 2, "c" => 3, "d" => 4, "e" => 5)
a = Array{String}
for k in keys(dict)
if dict[k] < 2
continue
end
push!(a, k) # building array from keys produces errors
end
ERROR: MethodError: `push!` has no method matching push!(::Type{Array{AbstractString,N}}, ::ASCIIString)
Hi,I have many problems to build arrays with the keys of a dictionary except for the simple situation :
a = [uppercase(key) for key in keys(dict)] # works fineIf I try to select the keys with more complex criteria like :
dict = Dict("a" => 1, "b" => 2, "c" => 3, "d" => 4, "e" => 5)
a = Array{String}
[k for k in keys(dict) if dict[k] < 2]
Hi Steven,
I also tried a = Array{String}() unfortunately it produces errors as well.
julia> a = Array{String}()
WARNING: Base.String is deprecated, use AbstractString instead.
likely near no file:0
0-dimensional Array{AbstractString,0}:
#undef
julia> for k in keys(dict)
if dict[k] < 2
continue
end
push!(a, k)
end
ERROR: MethodError: `push!` has no method matching push!(::Array{AbstractString,0}, ::ASCIIString)
Closest candidates are:
push!(::Any, ::Any, ::Any)
push!(::Any, ::Any, ::Any, ::Any...)
push!(::Array{Any,1}, ::ANY)
...
[inlined code] from none:5
in anonymous at no file:0
On Mon, 2016-11-07 at 15:27, Fred <fred.so...@gmail.com> wrote:
> Hi Steven,
>
>
> I also tried a = Array{String}() unfortunately it produces errors as well.
Array{String}(0)
a = Vector{String}
a = Vector{String}()
a = String[]