SplitScript reference / Iterator / map
Iterator.map
Method
T.map<T>(transform: (Item) -> U) -> MapIterator<T, Item, U> where T: Iterator
Lazily transforms every remaining item from this cursor.
The callback runs only when the returned iterator is advanced. The original cursor becomes the source owned by that adapter, so iterating the adapter continues from its current position.
Parameters
transform: Transformation applied to each yielded item.
Effects: pure
Runtime behavior: available everywhere; synchronous
Examples
Double values as they are consumed
let doubled = [1, 2, 3].iterator().map(value => value * 2)
for value in doubled {
print(value)
}