Reputation: 133
On the official lua wiki it states that this is how you make a module
local mymodule = {}
function mymodule.foo()
print("Hello World!")
end
return mymodule
But couldn't you just do
return { foo=function() print("Hello World!") end }
I am familiar with Lua but not an expert. So is there anything wrong with what I've written?
Upvotes: 2
Views: 61
Reputation: 72312
Your way is perfectly fine.
The example in the wiki is better suited for larger modules, with several functions and possibly private data.
Upvotes: 2