Multiple keys for one value

Is it there a way to assign multiple keys to a value in a dictionary?

That just works. Are you getting an error?

julia> Dict("a" => 1, "b" => 1, "c" => 1)
Dict{String, Int64} with 3 entries:
  "c" => 1
  "b" => 1
  "a" => 1

Or

julia> Dict(("a","b","c") .=> 1)
Dict{String, Int64} with 3 entries:
  "c" => 1
  "b" => 1
  "a" => 1
3 Likes

and if the Dict exists already you can use merge!.

x = Dict{Symbol, Int64}()
merge!(x, Dict((:a, :b, :c) .=> 1))
1 Like