Skip to content

Function: loop while for

Maciej Górski edited this page Jan 6, 2016 · 1 revision

Warning: imperative call!

function loop(condition: ()->boolean, block: ()->()) -> ()

Calls block until condition returns true. This uses functions that share some state, e.g. methods of the same object or variable defined prior to calling loop:

i = 0
loop({ i < 10 }, {
    print(i)
    i += 1
})

Clone this wiki locally