zoukankan      html  css  js  c++  java
  • 通过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
  • 相关阅读:
    二十三种设计模式 python实现
    python logging的输出
    redis
    Django1.11序列化与反序列化
    Django1.11基础视图
    Django1.11模型类数据库操作
    Django1.11创建
    泛型全面分析和应用(二)
    泛型全面分析和应用(一)
    注解的基本盘点 -- 《Java编程思想》
  • 原文地址:https://www.cnblogs.com/sdlypyzq/p/3002427.html
Copyright © 2011-2022 走看看