Q:

Is this a correct way of making modules in Lua?

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?

A:

Your way is perfectly fine.
The example in the wiki is better suited for larger modules, with several functions and possibly private data.

