2018-07-03 lua协程机制

2018-07-03  本文已影响0人  心想事成_ae7e

local co = coroutine.create(function(a,b,c)

print("co:",a,b,c)

end)

coroutine.resume(co,1,2,3)

co = coroutine.create(function(a,b)

print("co:",coroutine.yield(a+b,a-b))

end)

print(coroutine.resume(co,20,10))

co = coroutine.create(function( )

print("co:",coroutine.yield( ))

end)

coroutine.resume(co)

coroutine.resume(co,4, 5)

co = coroutine.create(function( )

return 6,7

end)

print(coroutine.resume(co))

上一篇 下一篇

猜你喜欢

热点阅读