Title here
Summary here
Lua has various value types including strings, numbers, booleans, etc. Here are a few basic examples.
-- Strings, which can be concatenated with ..
print("lua" .. "lang")
-- Numbers (Lua doesn't distinguish between integers and floats)
print("1+1 =", 1 + 1)
print("7.0/3.0 =", 7.0 / 3.0)
-- Booleans, with boolean operators as you'd expect
print(true and false)
print(true or false)
print(not true)
To run the program, save it as values.lua
and use the lua
command:
$ lua values.lua
lualang
1+1 = 2
7.0/3.0 = 2.3333333333333
false
true
false
In this example, we see:
..
operator.and
, or
, and not
.Note that Lua uses ..
for string concatenation instead of +
, and keywords like and
, or
, and not
for boolean operations instead of symbols.
Also, Lua doesn’t have a separate print function for each value; instead, multiple arguments to print
are separated by tabs in the output.