zoukankan      html  css  js  c++  java
  • 通过lua自带例子学习lua 02

    -- Example 6 -- Case Sensitive.

    -- Lua is case sensitive so all variable names & keywords
    -- must be in correct case.
    
    ab=1
    Ab=2
    AB=3
    print(ab,Ab,AB)
    
     
    
    -------- Output ------
    
    1 2 3

    -- Example 7 -- Keywords.

    -- Lua reserved words are: and, break, do, else, elseif,
    -- end, false, for, function, if, in, local, nil, not, or,
    -- repeat, return, then, true, until, while.
    
    -- Keywords cannot be used for variable names,
    -- 'and' is a keyword, but AND is not, so it is a legal variable name.
    AND=3
    print(AND)
    
     
    
    -------- Output ------
    
    3

    -- Example 8 -- Strings.

    a="single 'quoted' string and double \"quoted\" string inside"
    b='single \'quoted\' string and double "quoted" string inside'
    c= [[ multiple line
    with 'single'
    and "double" quoted strings inside.]]
    
    print(a)
    print(b)
    print(c)
    
    
    -------- Output ------
    
    single 'quoted' string and double "quoted" string inside
    single 'quoted' string and double "quoted" string inside
    multiple line
    with 'single'
    and "double" quoted strings inside.

    -- Example 9 -- Assignments.

    -- Multiple assignments are valid.
    -- var1,var2=var3,var4
    
    a,b,c,d,e = 1, 2, "three", "four", 5
    
    print(a,b,c,d,e)
    
     
    
    -------- Output ------
    
    1 2 three four 5

    -- Example 10 -- More Assignments.

    -- Multiple assignments allows one line to swap two variables.
    
    print(a,b)
    a,b=b,a
    print(a,b)
    
     
    
    -------- Output ------
    
    1 2
    2 1
  • 相关阅读:
    Linux系统下安装jdk1.8并配置java环境
    linux常用命令
    intelliJ IDEA 中快速定位当前文件路径
    Intellij IDEA 入门之java “Hello word”
    常用SQL语句
    PictureBox的内存问题
    MDI窗体设计
    实现多态的方法三——接口
    css清除浮动方法
    三栏式布局(下)
  • 原文地址:https://www.cnblogs.com/sdlypyzq/p/3002438.html
Copyright © 2011-2022 走看看