Created
June 26, 2012 16:07
-
-
Save rlorca/2996732 to your computer and use it in GitHub Desktop.
Coroutines in Lua
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
function foo () | |
return coroutine.yield("ho ho ho") | |
end | |
co = coroutine.create(function (a) | |
return foo() * a | |
end) | |
print("intermediate result", coroutine.resume(co, 3)) | |
print("final result", coroutine.resume(co, 7)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment