Swift: Printing out an associative array

This entry is part 9 of 41 in the series Swift

For an associative array, this is how I would print out the array.

import UIKit


var someArray: [Int:String] = [30:"Alex", 25:"Brian", 36: "Dave"]

for (index, element) in someArray {
    print(element)
}

print("");

for (element) in someArray {
    print(element)
}

swift

Series Navigation<< Swift: Printing out an array
Swift: Printing out the index in an array >>

Leave a comment

Leave a Reply