asIterator

inline fun <T> Flow<T>.asIterator(producerScope: CoroutineScope, crossinline hasNext: ChannelIterator<T>.() -> Boolean, crossinline next: ChannelIterator<T>.() -> T): Iterator<T>(source)

Converts a Flow into an Iterator by providing custom implementations for the hasNext and next functions.

Return

An Iterator that can be used to iterate over the elements in the Flow.

Parameters

producerScope

The CoroutineScope that the produced Flow will be associated with.

hasNext

A lambda expression that returns true if there are more elements in the Flow, or false otherwise.

next

A lambda expression that returns the next element in the Flow.