Hello I tried a print dictionary items at Xcode9. Like this:
var items = ["Bear":"0", "Glass":"1", "Car":"2"]
for (key,value) in items{
print("\(key) : \(value)")
}
output:
Glass : 1
Bear : 0
Car : 2
Why output not like this: Bear: 0, Glass:1, Car:2 I dont understand this output reason.
Dictionary :
A dictionary stores associations between keys of the same type and values of the same type in a collection with no defined ordering.
Each value is associated with a unique key, which acts as an identifier for that value within the dictionary. Unlike items in an array, items in a dictionary do not have a specified order.
Array - An array stores values of the same type in an ordered list.
Sets - A set stores distinct values of the same type in a collection with no defined ordering.
From Apple documentation
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With