SplitScript reference / Language / yield

yield

keyword

yield expression

Suspends a generator after producing one item.

yield is available only inside a function or closure explicitly returning iterator T. Its expression must have type T. The generator preserves its parameters, captures, and live locals, and the next Iterator.next continues immediately after the yield. It is distinct from return: a bare return exhausts the cursor, while returning a value is an error.

Examples

Produce the next item

yield value