关系运算符(false或true): 下面介绍If、For、While、Repeat 、Table、Concatenation以及Length operator#长度运算符:
2.5.4 –Concatenation The string concatenation operator in Lua is denoted by two dots ('..'). If both operands are strings or numbers, then they are converted to strings according to the rules mentioned in§2.2.1. Otherwise, the "concat" metamethod is called (see§2.8). 连接符号 .. 用...
-- Overload the add operation -- to do string concatenation -- mt = {} function String(string) return setmetatable({value = string or ''}, mt) end -- The first operand is a String table -- The second operand is a string -- .. is the Lua concatenate operator -- function mt.__...
-- Overload the add operation -- to do string concatenation -- mt = {} function String(string) return setmetatable({value = string or ''}, mt) end -- The first operand is a String table -- The second operand is a string -- .. is the Lua concatenate operator -- function mt.__...
write(name,..'=') -- write is a library function for output,'..'is the string concatenation operator write_value(value) -- outputs a suitablerepresentation of a value based on its type end function write_value(value) local t = type(value) ...
), logical operators (see2.5.3. Logical Operators), and the concatenation operator (see2.5.4. Concatenation). Unary operators comprise the unary minus (see2.5.1. Arithmetic Operators), the unarynot(see2.5.3. Logical Operators), and the unarylength operator(see2.5.5. The Length Operator)....
2.5.4 - Concatenation -The string concatenation operator in Lua is -denoted by two dots ('..'). -If both operands are strings or numbers, then they are converted to -strings according to the rules mentioned in §2.2.1. -Otherwise, the "concat" metamethod is called (see §2.8). - ...
Here are some examples: 10 or 20 10 or error() nil or "a" nil and 10 false and error() false and nil false or nil 10 and 20 --> 10 --> 10 --> "a" --> nil --> false --> false --> nil --> 20 3.4.6 Concatenation The string concatenation operator in Lua is denoted...
The string concatenation operator in Lua is denoted by two dots('..'). If both operands are strings or numbers, then the numbers are converted to strings in a non-specified format. Otherwise, the __concat metamethod is called. The Length Operator The length operator is denoted by the unar...
The string concatenation operator in Lua is denoted by two dots (’..’). You can getstdinandstdoutwithreadandwritefunctions iniolibrary While Loop sum=0num=1whilenum<=100dosum=sum+numnum=num+1endprint('sum = ', sum) For Loop