• 通过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
  • 相关阅读:
    php面向对象三大特性
    php面向对象的重写与重载
    一组成对的数字,找出不成对的数字
    如何创建dll以及使用
    常见运行时错误
    连续数的和
    绕圆圈取球
    第一章 概述
    错误2038
    一个简单的环境光shader
  • 原文地址:https://www.cnblogs.com/sdlypyzq/p/3002445.html
Copyright © 2020-2023  润新知