How do I add a method to the table type? I'm trying to write a method that searches through the values of a table. So far I have.
function table:contains(value)
for _, v in ipairs(self) do
if v == value then return true end
end
return false
end
Yet when I try to do the following.
t = {'four', 'five', 'six'}
t:contains('five')
I get the error.
stdin:1: attempt to call method 'contains' (a nil value)
Any suggestions?