iterableWith

fun <X> X?.iterableWith(advance: (X) -> X?): Iterable<X>

Create an Iterable, starting with the receiver. The iterator produces successive values by applying advance until null is reached. The receiver is also allowed to be null, which indicates an empty iterator.

Receiver

The initial value, if any, returned by the iterator.

Return

An Iterable. If the action is non-destructive, an Iterator of X can be constructed multiple times, each time beginning from the same starting point.

Parameters

advance

A function to extract the next value from the current value, such as by traversing a null-terminated singly-linked list.