欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

Lua之wrap函數(shù)用法示例

 更新時(shí)間:2015年04月22日 09:29:25   投稿:junjie  
這篇文章主要介紹了Lua之wrap函數(shù)用法示例,本文同時(shí)總結(jié)了wrap和Create的區(qū)別,需要的朋友可以參考下

wrap和Create差不多,都是去創(chuàng)建一個(gè)coroutine,有些區(qū)別:

1,wrap不會(huì)通過(guò)resume去得到第一個(gè)返回值(錯(cuò)誤信息)
2,在創(chuàng)建完之后,直接調(diào)用函數(shù),轉(zhuǎn)到coroutine,而create卻要resume才能轉(zhuǎn)到coroutine。
3,wrap不能查看狀態(tài)。

例子代碼:

復(fù)制代碼 代碼如下:

do 
    function createWrap() 
        return coroutine.wrap(function(x) 
                                    print("Hello", x); 
                                    coroutine.yield(); 
                                    print("continue") 
                                end); 
    end 
 
    coA = createWrap(); --get the function, resum the coroutine 
    coA(3); 
    coA(3); --call the global function, , resum the coroutine 
 
end

相關(guān)文章

最新評(píng)論