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

    -- Example 11 -- Numbers.

    -- Multiple assignment showing different number formats.
    -- Two dots (..) are used to concatenate strings (or a
    -- string and a number).
    
    a,b,c,d,e = 1, 1.123, 1E9, -123, .0008
    print("a="..a, "b="..b, "c="..c, "d="..d, "e="..e)
    
     
    
    -------- Output ------
    
    a=1 b=1.123 c=1000000000 d=-123 e=0.0008

    -- Example 12 -- More Output.

    -- More writing output.
    
    print "Hello from Lua!"
    print("Hello from Lua!")
    
     
    
    -------- Output ------
    
    Hello from Lua!
    Hello from Lua!

    -- Example 13 -- More Output.

    -- io.write writes to stdout but without new line.
    
    io.write("Hello from Lua!")
    io.write("Hello from Lua!")
    
    -- Use an empty print to write a single new line.
    print()
    
     
    
    -------- Output ------
    
    Hello from Lua!Hello from Lua!

    -- Example 14 -- Tables.

    -- Simple table creation.
    
    a={} -- {} creates an empty table
    b={1,2,3} -- creates a table containing numbers 1,2,3
    c={"a","b","c"} -- creates a table containing strings a,b,c
    print(a,b,c) -- tables don't print directly, we'll get back to this!!
    
    
    -------- Output ------
    
    table: 001EC6D0 table: 001EC7E8 table: 001EC860

    -- Example 15 -- More Tables.

    -- Associate index style.
    
    address={} -- empty address
    address.Street="Wyman Street"
    address.StreetNumber=360
    address.AptNumber="2a"
    address.City="Watertown"
    address.State="Vermont"
    address.Country="USA"
    
    print(address.StreetNumber, address["AptNumber"])
    
     
    
    -------- Output ------
    
    360 2a
  • 相关阅读:
    SQL的高级属性-
    查询
    SQL语句
    CSS的创建样式
    表单部分属性值
    HTML的语法和基本标签
    网页制作与HTML基本结构
    小程序button 去边框
    关于axios跨域带cookie
    Uncaught Error: code length overflow. (1604>1056)
  • 原文地址:https://www.cnblogs.com/sdlypyzq/p/3002445.html
Copyright © 2011-2022 走看看