Lover of life, just trying to become the best version of me...
Get notified when a new post is published.
Create an empty table -
a = {}
Create a table with the numbers 1,2,3 assigned -
b = {1,2,3}
Create a table with the strings "a","b","c" assigned -
c = {"a","b","c"}
We are unable to call print() on tables directly. See Printing tables.
You can use the print() function to write a line to the stdout.
print("Hello"), or print "Hello"
io.write("Hello")
You are able to make multiple assignments at the same time.
a,b,c,d,e = 1, 2, "three", "four", 5
The above assign is equivalent to the code below.
a = 1 b = 2 c = "three" d = "four" e = 5
a = 1 b = 2 a,b = b,a now a = 2 and b = 1
value="single 'quoted' string and double \"quoted\" string", or value='single \'quoted\' string and double "quoted" string', or value=[[multiple linewith 'single'and "double" quoted strings inside]]
The following words are all reserved for internal functions in Lua.
and, break, do, else, elseif, end, false, for, function, if, in, local, nil, not, or, repeat, return, pairs, then, true, until, while
These words cannot be used for variable names, but Lua is case sensitive, so 'and' is reserved and can't be a variable, but 'aND, aNd, AND, anD, AnD, And, ANd' are not reserved and can be used as variables.