Create a program to transverse the elements of a sequence using for loop. Elements would be rainbow colours.
Answers
Answered by
0
ANSWER:
Swift IteratorProtocol and Sequence are two extremely powerful protocols which allow developers to iterate over a sequence of values.
IteratorProtocol provide the next value in a sequence. If the next value is nil then a sequence will stop iterating. It may also contain state information about the iteration.
Sequence: “A type commonly used to iterate through a for-in loop”. ~ Apple.
If you have used a Collection or a for-in loop then you’ve encountered these two protocols. However, these protocols can be applied to things other than collections.
Similar questions