Difference between revisions of "Module:Sandbox/Erutuon/random"
< Module:Sandbox | Erutuon
Jump to navigation
Jump to search
blackwiki>Erutuon (list script codes in Template:ISO 15924 script codes and related Unicode data) |
blackwiki>Erutuon (convenient output class) |
||
| Line 1: | Line 1: | ||
| − | + | local p = {} | |
| − | local | + | local Out_mt = {} |
| + | Out_mt.__index = Out_mt | ||
| + | |||
| + | function Out_mt:add(item) | ||
| + | self.i = self.i + 1 | ||
| + | self[self.i] = item | ||
| + | end | ||
| + | |||
| + | function Out_mt:__tostring() | ||
| + | return table.concat(self) | ||
| + | end | ||
| + | |||
| + | function Out() | ||
| + | local o = setmetatable({}, Out_mt) | ||
| + | o.i = 0 | ||
| + | return o | ||
| + | end | ||
function p.show(frame) | function p.show(frame) | ||
| − | local | + | local out = Out() |
| − | + | out:add('hello') | |
| − | + | return out | |
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | return | ||
end | end | ||
return p | return p | ||
Revision as of 21:58, 26 May 2018
Test
- hello
local p = {}
local Out_mt = {}
Out_mt.__index = Out_mt
function Out_mt:add(item)
self.i = self.i + 1
self[self.i] = item
end
function Out_mt:__tostring()
return table.concat(self)
end
function Out()
local o = setmetatable({}, Out_mt)
o.i = 0
return o
end
function p.show(frame)
local out = Out()
out:add('hello')
return out
end
return p