lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]




Le mar. 3 août 2021 à 21:21, Soni "They/Them" L. <fakedme@gmail.com> a écrit :
Lua has this neat syntax for relative submodules: require(.....".foo").
Wondering if anyone else uses these?

e.g.

-- file foo.lua
local bar = require(.....".bar")
local M = {bar = bar}
return M

-- file foo/bar.lua
local M = {}
return M

conversely, (and I used it):

-- file foo/bar.lua
local parent = require(string.gsub(..., '%.%w+$', ''))  -- ie. require('foo')

but it doesn't have the magic aspect of 5 (3+2) dots.