Skip to content

Instantly share code, notes, and snippets.

@remyroez
Created February 25, 2020 11:21
Show Gist options
  • Save remyroez/baa67504e7fcdea405465b2f5a68b0b3 to your computer and use it in GitHub Desktop.
Save remyroez/baa67504e7fcdea405465b2f5a68b0b3 to your computer and use it in GitHub Desktop.
lua syntax sugar for basic values(number, function, coroutine)
-- https://stackoverflow.com/questions/33988610/weird-behavior-of-syntax-sugarcolon-in-lua
local debug = require 'debug'
debug.setmetatable(0, { __index = math })
debug.setmetatable(function() end, { __index = coroutine })
debug.setmetatable(coroutine.create(function() end), { __index = coroutine })
local table = require 'table'
table.new = function (self, t)
t = t or self
return setmetatable(t, { __index = table })
end
setmetatable(table, { __call = table.new })
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment