🚀 coroutine.resume can pass arguments

This commit is contained in:
ValKmjolnir
2023-01-02 18:53:58 +08:00
parent e6e89039b8
commit 48611c50f7
7 changed files with 36 additions and 9 deletions

View File

@@ -40,6 +40,20 @@ func(){
}
}();
# test coroutine.resume passing arguments to coroutine
func{
var co=coroutine.create(func(){
var (a,b)=coroutine.yield(a+b);
println("coroutine.yield get ",a," ",b);
(a,b)=coroutine.yield(a+b);
println("coroutine.yield get ",a," ",b);
return "end";
});
for(var i=0;i<5;i+=1)
println("coroutine.resume get ",coroutine.resume(co,i,i+1));
}();
# test crash in coroutines
var co=coroutine.create(func{
var b=func(){b()}