Swift: Printing out the index in an array

This entry is part 10 of 41 in the series Swift

As for printing out the index in an associative array.

import UIKit


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

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

swift

Series Navigation<< Swift: Printing out an associative array
Swift: A function that returns a string >>

Leave a comment

Leave a Reply