Skip to content

Instantly share code, notes, and snippets.

@mraleph
Last active November 29, 2017 09:03
Show Gist options
  • Save mraleph/1e584810340d28886911d45af74c568d to your computer and use it in GitHub Desktop.
Save mraleph/1e584810340d28886911d45af74c568d to your computer and use it in GitHub Desktop.
╰─$ lua /tmp/x.lua
true I yielded
I resumed
true I am done
local yield, resume = coroutine.yield, coroutine.resume
function f(g)
g()
return 'I am done'
end
function g()
print(yield("I yielded"))
end
local co = coroutine.create(f)
print(resume(co, g))
print(resume(co, "I resumed"))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment