repeat
Calls action with each index from zero until times, or not at all for non-positive counts.
Indexes are visited in ascending order. Exceptions from action stop iteration and propagate to the caller. The inline action supports non-local returns.
repeat(3) { index -> println(index) }Content copied to clipboard
Parameters
times
number of calls; zero and negative counts do nothing.
action
callback receiving the current zero-based index.