摘要:
function foo() print(g or "'g' is not defined!")endfoo()env = { g = 100, print = print }setfenv(foo, env) --设置foo的环境为表envfoo()print(g or "'g' is not d... 阅读全文
摘要:
迭代function enum(array) local index = 1 return function() --返回迭代函数 local ret = array[index] index = index + 1 return ret endendfunction foreach(array, ... 阅读全文