首页 > 学院 > 开发设计 > 正文

lua select 用法

2019-11-08 01:59:28
字体:
来源:转载
供稿:网友

调用select时,必须传入一个固定实参selector(选择开关)和一系列变长参数。如果selector为数字n,那么select返回它的第n个可变实参,否则只能为字符串"#",这样select会返回变长参数的总数。例子代码:

do      function foo(...)          for i = 1, select('#', ...) do //get the count of the params              local arg = select(i, ...);//select the param              PRint("arg", arg);          end      end        foo(1, 2, 3, 4);  end  


发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表