How to access Dictionary keys with Variable

Create a Dictionary of Maps

maps = Dict(:Arad => Dict(:Zerinda => 75,:Sibiu => 140,:Timisora => 118))

Access Arad key works with the below code


Access nested key works with the below code


Access key with getindex method work with the below code


Access nested key with getindex works with the below code


Assign a variable

startpos = “Arad”

Here is my issue. How can i get key and nested key value using the variable ? few example I have issues.



Please read PSA: how to quote code with backticks and update your post.

Use startpos = :Arad (which is the same you used when you used the key directly)

1 Like

Thanks it worked. Appreciate for your quick response.