Array as a dictionary value in swift language -


i have following swift dictionary

var list = [     2543 : [ "book", "pen" ],    2876 : [ "school", "house"] ] 

how can access array values ?

println(list[2543][0])  

the above code gives error "could not find member subscript"

and should print "book"

note subscript returns optional. have force unwrapping:

println(list[2543]![0]) 

or use optional chaining

println(list[2543]?[0]) 

Comments

Popular posts from this blog

C# random value from dictionary and tuple -

cgi - How do I interpret URLs without extension as files rather than missing directories in nginx? -

.htaccess - htaccess convert request to clean url and add slash at the end of the url -