A Module is like a library full of functions and variables.
info.lua
:
local M = {}
function M.valueOf(x)
io.write("Value: ", x)
end
return M
main.lua
:
local info = require("info")
info.valueOf("John")
$ lua main.lua
Value: John
Lua by Example
A Module is like a library full of functions and variables.
info.lua
:
local M = {}
function M.valueOf(x)
io.write("Value: ", x)
end
return M
main.lua
:
local info = require("info")
info.valueOf("John")
$ lua main.lua
Value: John