Last active
November 29, 2017 09:03
-
-
Save mraleph/1e584810340d28886911d45af74c568d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
╰─$ lua /tmp/x.lua | |
true I yielded | |
I resumed | |
true I am done |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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