You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When I use collect on a dictionary from base, I get a vector with Key-Value pairs.
But when I use collect on a Dictionaries.Dictionary, I just get a vector of values.
julia> base =Dict("Test1"=>1, "Test2"=>2)
Dict{String, Int64} with 2 entries:"Test2"=>2"Test1"=>1
julia> other = Dictionaries.Dictionary(base)
2-element Dictionaries.Dictionary{String, Int64}
"Test2" │ 2"Test1" │ 1
julia>collect(base)
2-element Vector{Pair{String, Int64}}:"Test2"=>2"Test1"=>1
julia>collect(other)
2-element Vector{Int64}:21
Is there a reason for this behavior? Is there possibly an alternative I can use to get similar behavior? I am relatively new to Julia and especially this package.
I would like to iterate over the (collected) dictionary keys and values using numbered indices since i use the same index for other vectors.
The text was updated successfully, but these errors were encountered:
One of the purposes of Dictionaries is to be able to iterate on Dictionary (which is not currently possible: try map(dict) or f.(dict)).
The decision was made that the iteration in Dictionary is done on the values. So collect naturally return the collected iterator i.e. a vector of the values.
You can get a more similar behavior by calling pairs :
When I use collect on a dictionary from base, I get a vector with Key-Value pairs.
But when I use collect on a Dictionaries.Dictionary, I just get a vector of values.
Is there a reason for this behavior? Is there possibly an alternative I can use to get similar behavior? I am relatively new to Julia and especially this package.
I would like to iterate over the (collected) dictionary keys and values using numbered indices since i use the same index for other vectors.
The text was updated successfully, but these errors were encountered: