lua-模块

    技术2022-07-10  120

    --模块:相当于库,把一些公用的变量、函数放在一个table表中。这样有利于提高代码的重用和降低代码的耦合度 module = {} --定义一个常量 module.constant = 1 --定义一个函数 function module.func1() print("Func1") end --私有函数 local function func2() print("Private Func2") end --函数 function module.func3() func2() end return module --模块使用方式 --普通使用 require("module") print(module.constant) module.func3() --使用别名 m = require("module") m.func3()
    Processed: 0.011, SQL: 9