Reputation: 4485
Is it possible to extend (or even override) standard library modules. I'd like to be able to do something like
-- eggs.lua
table.spam = function(tab)
return tab[1]
end
and then
-- ham.lua
require('eggs')
table.spam({2,7,1,3})
Upvotes: 3
Views: 469
Reputation: 26774
Yes, it's possible, although the recommendation would be not to modify the standard library namespace, but use tablex
instead as some libraries do.
Upvotes: 1