Skip to content

Instantly share code, notes, and snippets.

@b0mbie
Last active May 11, 2023 10:44
Show Gist options
  • Select an option

  • Save b0mbie/11154d2492742e20710f163dedf09326 to your computer and use it in GitHub Desktop.

Select an option

Save b0mbie/11154d2492742e20710f163dedf09326 to your computer and use it in GitHub Desktop.
Lua one-liner that adds a __call metamethod to numbers which multiplies given parameters with self and returns them.
local s,u=select,table.unpack or unpack debug.setmetatable(3,{__call=function(x,...)local n,t=s('#',...),{}for i=1,n do t[i]=x*s(i,...) end return u(t,1,n)end})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment