Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/lua/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Lua中的词汇标记_Lua - Fatal编程技术网

Lua中的词汇标记

Lua中的词汇标记,lua,Lua,来自博士 以下字符串表示其他标记: + - * / % ^ # == ~= <= >= < > = ( ) { } [ ] ; : , . .. ... +-*/%^# == ~= = < > = ( ) { } [ ] ;

来自博士

以下字符串表示其他标记:

 +     -     *     /     %     ^     #
 ==    ~=    <=    >=    <     >     =
 (     )     {     }     [     ]
 ;     :     ,     .     ..    ...
+-*/%^#
==    ~=    =    <     >     =
(     )     {     }     [     ]
;     :     ,     .     ..    ...
什么?还有。。。平均值?

是a,
..
是a。

符号用于获取集合的长度(数组、字符串等)

符号表示函数具有数量可变的参数

function print (...)
  for i,v in ipairs(arg) do
    result = result .. tostring(v) .. "\t"
  end
end

ipairs(arg)
不正确;应该是
ipairs({…})
或者更好地使用
select('#',…)
来避免参数中的
nil
问题。@PaulKulchenko在ipairs({…})中{}的用法是什么,为什么不是ipairs(…)?因为
ipairs(…)
将参数列表传递给
ipairs
。如果第一个元素是一个数字,你会得到一个错误,比如'ipairs'(需要表格,得到数字)。
ipairs
使用不当,因为
print(“Now you see it”,nil,“Now you not”)
不会遍历整个列表。手册没有解释它们吗??
function print (...)
  for i,v in ipairs(arg) do
    result = result .. tostring(v) .. "\t"
  end
end