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

database - VFP Grid + SQL server 2008 - grid not showing correctly -

jquery - Set jPicker field to empty value -

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