API/Enumerator

Enumerator.New(initialize, try_get_next, dispose)

Construct and return a new Enumerator

Parameters

initialize
nil or a function that will be called no more than, before the first iteration.
try_get_next
a function that will be passed a yielder that should call the yielder or return false and will be called multiple times.
dispose
nil or a function that will be called once once iteration is complete.


Enumerator.prototype:Current()

Return the last-yielded value in the Enumerator, or nil if the Enumerator no longer has a yielder.

Return value

The current value of the Enumerator or nil.


Enumerator.prototype:Dispose()

Dispose the enumerator, making it so :MoveNext() always return false, and clear out any memory possible.
This can be called more than once without issue.


Enumerator.prototype:MoveNext()

Advances the Enumerator to the next item in the sequence

Return value

whether the Enumerator successfully advanced, false if passed the end of the sequence.


Enumerator.prototype:ToString()

Return a string representation of the Enumerator

Return value

a string


Yielder.New()

Return a new yielder with no current value

Return value

a Yielder


Yielder.prototype:Current()

Return the current value in the yielder.

Return value

the last yielded value


Yielder.prototype:Yield(value)

Yield a new value, setting the value in the yielder and returning true.
This can also be accessed by calling the yielder directly.

Parameters

value
the value to set the yielder's internal value to

Return value

true



Comments

Posts Quoted:
Reply
Clear All Quotes