← All speaking

Dualizing IEnumerable and IEnumerator

.NET Fringe

IEnumerable and IEnumerator are a pretty rad pair of interfaces. They give us an abstraction over working with synchronous collections.

A synchronous collection is a list of things that have already been evaluated. The IEnumerable/IEnumerator pair lets us pull items from an already-evaluated collection.

Through some clever maths, a process known as dualizing, we can flip IEnumerable and IEnumerator around to support a push-based interaction pattern: the IObservable/IObserver pair, the building blocks of Reactive Extensions.