How to create a dictionary in Swift

2 Answers

0 votes
var dict:[String:Int] = ["Swift":3, "Java":9, "C":5] 

print(dict)






/*
run:

["Java": 9, "C": 5, "Swift": 3]

*/

 



answered Jun 14, 2023 by avibootz
0 votes
var dict = [4:"Swift", 7:"Java", 10:"C"] 

print(dict)






/*
run:

[10: "C", 4: "Swift", 7: "Java"]

*/

 



answered Jun 14, 2023 by avibootz

Related questions

...