Homepage / Notes / Computer Science / Programming Languages / Lua
Lightweight, embeddable scripting language
return "Hello, Lua!"
Hello, Lua!
print("Hello, Lua!")
Hello, Lua!
if true then
return 'this is true'
else
return 'this is false'
end
this is true
function double(x)
return x * 2
end
return double(2)
4
t = {key1 = 'value1', key2 = 'value2'}
return t.key1
value1
"List" (actually a table with consecutive integer keys) Return the length of the list:
v = {'value1', 'value2', 'value3'}
return #v
3
Indices start at 1
v = {'value1', 'value2', 'value3'}
return v[2]
value2