Editing Module:Template test case

Warning: You are not logged in. Your IP address will be publicly visible if you make any edits. Read the Privacy Policy to learn what information we collect about you and how we use it.

If you log in or create an account, your edits will be attributed to your username, along with other benefits.

The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then publish the changes below to finish undoing the edit.

Latest revision Your text
Line 75: Line 75:


-- Memoize expensive method calls
-- Memoize expensive method calls
local memoFuncs = {}
local memoizedValues = {}
return setmetatable(obj, {
return setmetatable(obj, {
__index = function (t, key)
__index = function (t, key)
if Template.memoizedMethods[key] then
if Template.memoizedMethods[key] then
local func = memoFuncs[key]
local val = memoizedValues[key]
if not func then
if val then
local val = Template[key](t)
return val
func = function () return val end
else
memoFuncs[key] = func
val = Template[key](t)
memoizedValues[key] = val
return val
end
end
return func
else
else
return Template[key]
return Template[key]
Please note that all contributions to Nonbinary Wiki are considered to be released under the Creative Commons Attribution-ShareAlike (see Nonbinary Wiki:Copyrights for details). If you do not want your writing to be edited mercilessly and redistributed at will, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource. Do not submit copyrighted work without permission!
Cancel Editing help (opens in new window)

Template used on this page: