why does the for loop in Swift Playground iterates over each element in a random order? I thought for loops iterate from the first element going to the last?
What does surprise you ? Is it this order:
key: Prime
key: Square
key: Fibonacci
and the fact that it changes at each iteration ?
key: Square
key: Prime
key: Fibonacci
That's normal in Swift (not specific to playgrounds).
That's because you loop through a dictionary and there is no order in a dictionary, contary to Array. Note that there is no order either in Sets.
That's explicit in Swift programming Language :