Jak dodać metodę do typu tabeli?
Jak dodać metodę do typu tabeli? Próbuję napisać metodę, która przeszukuje wartości tabeli. Do tej pory mam.
function table:contains(value)
for _, v in ipairs(self) do
if v == value then return true end
end
return false
end
Jednak gdy próbuję wykonać następujące czynności.
t = {'four', 'five', 'six'}
t:contains('five')
Dostaję błąd.
stdin:1: attempt to call method 'contains' (a nil value)
Jakieś sugestie?