foo:gsub("%s*$", "")
or foo:gsub("^%s*", "")
The standard idiom for OOP in Lua is a one-liner: return setmetatable(self, mt)
where mt.__index has all the methods. How you assign to mt.__index can vary across modules according to style, but that's a _purely_ asethetic issue. The mechanics are identical. Using a module to accomplish it creates a useless dependency.There are many criticisms one could make of Lua, but I don't think those two particular criticisms are legit. They're classic bikeshedding.