Creating Dictionaries from Arrays in Julia
Code 1
julia> Dict(["a", "bc"] .=> [2,8])
Dict{String, Int64} with 2 entries:
"a" => 2
"bc" => 8
Given two arrays you want to use as keys and values, you can create a dictionary using Dict(Key .=> Value)
. Essentially, it’s nothing more than broadcasting the =>
operator to create pairs.
Environment
- OS: Windows
- julia: v1.7.0