[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Problem extending a table
- From: Peter Hickman <peterhi@...>
- Date: Sat, 14 Feb 2009 14:02:20 +0000
I have some code that I want to use to add an invert method to tables.
table.invert = function (t)
local i = {}
for k in pairs(t) do
i[t[k]] = true
end
return i
end
When I call it as "table.invert(a)" it works fine, but it errors when
I call it as "a:invert()"
lua: invert.lua:15: attempt to call method 'invert' (a nil value)
My understanding was that a:invert() was just sugar on
table.invert(a), what am I doing wrong?