3 ms·
> What can you do with a closure? You can call it. What can you do with an object? You can not call it. It's a good thing Lua doesn't have objects! Because in
by samatman 4y ago
> What can you do with a closure? You can call it. What can you do with an object? You can not call it.
It's a good thing Lua doesn't have objects!
Because in Lua, you can call a table if it has a `__call` metamethod, this is valid Lua:
(setmetatable({a = 5}, {__call = function(t) return t.a end}))()
which returns 5.