AsyncSequence
Andrés Ibañez Kautsch · Apress eBooks · 2022
In Swift, we have the concept of Sequences . Formally, Sequence is a protocol that types that need sequential and iterated access to their elements depend on. Arrays conform to Sequence , because you can iterate through them via a for-in loop, the forEach method, and with higher-order functions such as filter , map , and reduce . You can simply access their elements with a numbered index such as myArray[2] . Dictionaries are very similar. You can iterate over their keys and values in the same ways as an array, and to access an element in a dictionary, you can simply call myDictionary[myHashableKey]. Sets behave similarly, and you can even implement your own types that conform to Sequence .