On Fri, Jan 31, 2014 at 12:30 PM, Elias Barrionovo
<elias.tandel@gmail.com> wrote:
Since we're talking 'bout cool metatricks, here's a fun, but mostly useless one:
setmetatable(_G, {__index = function(_, v) return v end})
debug.getmetatable('').__sub = function(s1, s2) return s1..' '..s2 end
print(hello - world)
--
NI!
() - www.asciiribbon.org
/\ - ascii ribbon campaign against html e-mail and proprietary attachments
Functions also have metatables, which can be interesting:
> debug.setmetatable(print, {__concat=function(a,b) return function(...) return b(a(...)) end end})
> f = string.reverse .. string.upper
> =f('hello')
OLLEH
--
Sent from my Game Boy.