0 votes
185 views
asked in Swift by (4k points)
Hi all

   Apple Swift : how to use dictionary in for loop?

1 Answer

0 votes
answered by (4.2k 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

        }

    }

}

Categories

...