• 通过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
  • 相关阅读:
    <SpringMvc>入门二 常用注解
    <SpringMvc>入门一 HelloWorld
    <MyBatis>入门六 动态sql
    <MyBatis>入门五 查询的返回值处理
    <MyBatis>入门四 传入的参数处理
    <MyBatis>入门三 sqlMapper文件
    <MyBatis>入门二 全局配置文件
    <MyBatis>入门一 HelloWorld
    类和类的继承(6)
    python 的重载
  • 原文地址:https://www.cnblogs.com/sdlypyzq/p/3002438.html
Copyright © 2020-2023  润新知