How to create dictionary in Swift

2 Answers

0 votes
var dic = [String: Int]()

dic["swift"] = 76
dic["c++"] = 3
dic["python"] = 918


print(dic)





/*
run:

["swift": 76, "python": 918, "c++": 3]

*/

 



answered Sep 19, 2020 by avibootz
0 votes
var dic = [String: Int]()

dic["swift"] = 76
dic["c++"] = 3
dic["python"] = 918

print(dic["swift"]!)





/*
run:

76

*/

 



answered Sep 19, 2020 by avibootz

Related questions

...