What is a Dictionary?
A Dictionary is similar to an Array, it's a list of items, but in this case, it's unordered, and we define the index ourselves.
This means that a Dictionary is composed of a list of pairs where one component is the Key, and the other is the Value.
A Dictionary is declared similarly to an Array, but the Key-Value pairs are separated by colons. When specifying the type, we define the type of Key (on the left), and the type of Value (on the right).
var ages: [String: Int] = ["Pablo": 23, "Andrea": 21, "Miguel": 24]
var products: [Int, String] = [2341: "Pants", 33454: "Blouse", 2345: "Socks"]
Continue reading
Access to all the content with our plans.
- Junior level content
- Senior level content
- Expert level content
- Extra content
- Question submissions
Monthly
Yearly
Be the first to comment