Lua - Miscellaneous operators



Miscellaneous operators supported by Lua Language include concatenation and length.

Operator Description Example
.. Concatenates two strings. a..b where a is "Hello " and b is "World", will return "Hello World".
# An unary operator that return the length of the a string or a table. #"Hello" will return 5

Example

Try the following example to understand the miscellaneous operators available in the Lua programming language −

a = "Hello "
b = "World"

print("Concatenation of string a with b is ", a..b )

print("Length of b is ",#b )

print("Length of b is ",#"Test" )

When you build and execute the above program, it produces the following result −

Concatenation of string a with b is 	Hello World
Length of b is 	5
Length of b is 	4
lua_operators.htm
Advertisements