Skip to content

Instantly share code, notes, and snippets.

View MaxDesiatov's full-sized avatar
🇺🇦
#StandWithUkraine

Max Desiatov MaxDesiatov

🇺🇦
#StandWithUkraine
View GitHub Profile
@MaxDesiatov
MaxDesiatov / swift-generators.md
Last active September 12, 2018 13:24
Pitch for generator syntax in Swift

Pitch for generators, coroutines and a smooth path to async/await in Swift

Generator use case: streams

Streams in programming is an important concept. It allows you to handle high volumes of data without consuming much memory. A stream is an object that holds internal state (say reader position in a file) and can produce new values when requested.

Here's an example of a reader stream that reads a file in chunks in Swift 4.2:

final class ChunkReader {