Jump to content
Wikimedia Commons

Module:Bananas

From Wikimedia Commons, the free media repository
Lua

Code Discussion Edit History Links Link count Subpages: Documentation Tests Results Sandbox Live 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]]
 localp={}

 functionp.hello()
 return"Hello, world!"
 end

 setmetatable(p,{
 quickTests=function()
 iftype(p.hello())~='string'thenreturnfalse,'there was an error'end
 returntrue
 end
 })
 returnp

AltStyle によって変換されたページ (->オリジナル) /