lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


For some slightly early "It's Friday" discussion, what do you use the
__call metamethod for? Discuss your favorite hacks, strange problems
solved, code golf hole-in-ones, etc.

To get discussion started, I'll leave this here:

t = setmetatable({}, {__index = table, __call = function(t, method)
return function(...) t[method](t, ...) end end}) -- create a method
binding
string.gsub("foo", ".", t "insert")
for k,v in pairs(t) do print(k,v) end --> 1 f \n 2 o \n 3 o \n

-- 
Patrick Donnelly