Apple Swift : how to use dictionary in for loop?

0 votes
184 views
asked Jun 25, 2014 in Swift by kalpana (3,995 points)
Hi all

   Apple Swift : how to use dictionary in for loop?

1 Answer

0 votes
answered Jun 25, 2014 by john (4,220 points)

Hi all

 let interestingNumbers = [

    "Prime": [2, 3, 5, 7, 11, 13],

    "Fibonacci": [1, 1, 2, 3, 5, 8],

    "Square": [1, 4, 9, 16, 25],

]

var largest = 0

for (kind, numbers) in interestingNumbers {

    for number in numbers {

        if number > largest {

            largest = number

        }

    }

}

...