Module:Bananas

From Wikimedia Commons, the free media repository
Jump to navigation Jump to search
Lua

CodeDiscussionEditHistoryLinksLink count Subpages:DocumentationTestsResultsSandboxLive code All modules


Module:Bananas (talk · edit · hist · links · doc · subpages · tests / results · sandbox · all modules)

Example Lua module that contains a single function.

hello[edit]

  • {{#invoke:bananas|hello}} → Hello, world!

Code

-- For unit tests, see [[Module:Bananas/tests]]
local p = {}
 
function p.hello()
    return "Hello, world!"
end

setmetatable(p, {
    quickTests = function ()
        if type(p.hello()) ~= 'string' then return false, 'there was an error' end 
        return true
    end
} )
return p