Constructing a Dict but not sure WHY it works

That’s not an () for Any, that’s just the () that instantiates an empty Dict:

julia> Dict{String, Any} # This is just a type, not an object of the type!
Dict{String, Any}

julia> Dict{String, Any}() # Adding the () actually creates an instance of this type
Dict{String, Any}()

julia> Dict(letter => Dict{String, Any}() for letter ∈ 'a':'e') # a dict comprehension creates a dict where the values are other dicts
Dict{Char, Dict{String, Any}} with 5 entries:
  'a' => Dict()
  'c' => Dict()
  'd' => Dict()
  'e' => Dict()
  'b' => Dict()
2 Likes