通过lua自带例子学习lua 01

-- Example 1   -- First Program.

-- Classic hello program.

print("hello")

-------- Output ------

hello

-- Example 2   -- Comments.

-- Single line comments in Lua start with double hyphen.

--[[ Multiple line comments start
with double hyphen and two square brackets.
  and end with two square brackets. ]]

-- And of course this example produces no
-- output, since it's all comments!



-------- Output ------

-- Example 3 -- Variables.

-- Variables hold values which have types, variables don't have types.

a=1
b="abc"
c={}
d=print

print(type(a))
print(type(b))
print(type(c))
print(type(d))


-------- Output ------

number
string
table
function


-- Example 4 -- Variable names.

-- Variable names consist of letters, digits and underscores.
-- They cannot start with a digit.

one_two_3 = 123 -- is valid varable name

-- 1_two_3 is not a valid variable name.



-------- Output ------


-- Example 5 -- More Variable names.

-- The underscore is typically used to start special values
-- like _VERSION in Lua.

print(_VERSION)

-- So don't use variables that start with _,
-- but a single underscore _ is often used as a
-- dummy variable.



-------- Output ------

Lua 5.1
原文地址:https://www.cnblogs.com/sdlypyzq/p/3002427.html