I thought I remembered reading somewhere that it’s better to require a module just before you need it, but for the life of me I can’t find it now. I’ve taken the lazy way out, requiring modules I need at the top of my modules:
local Utility = require("Utility")
...
local function foo()
local b = Utility.getB()
-- do something with b
end
Would it be better to write the above like this, and if so, why?
local function foo()
local Utility = require("Utility")
local b = Utility.getB()
-- do something with b
end
[import]uid: 58455 topic_id: 27173 reply_id: 327173[/import]