Skip to main content

resume

Function resume 

Source
pub fn resume(co: thread, values: Repeatable<any>) -> (boolean, Repeatable<any>)
Expand description

Starts or continues the execution of the coroutine co. On the first resume, the values are passed as arguments to the body function; on later resumes, they become the results of the pending coroutine.yield.

Returns true plus any values yielded or returned by co, or false plus an error message if the coroutine raised an error.

§Examples

local co = coroutine.create(function(x, y) return x + y end)
print(coroutine.resume(co, 3, 4))    --> true   7
print(coroutine.resume(co))          --> false   cannot resume dead coroutine