Here is an error I'm having trouble tracking down.
Message: Interface\AddOns\SandBox\libs\UnitTests.lua:38: attempt to call method 'is_a' (a string value)
Here's my class declaration followed by the _init(...) definition
Lua Code:
Slot = {}
Slot.__index = Slot
setmetatable(Slot, {
__index = Container, -- makes the inheritance work
__call = function (cls, ...)
local self = setmetatable({}, cls)
self:_init(...)
return self
end,
})
-- This is the _init function.
function Slot:_init( bagNumber, slotIndex )
Container._init(self) -- call the base class constructor
self.is_a = "Slot" -- in the parent class, this is set to "Virtual Container"
end
-- the is_a() method
function Slot:is_a()
return self.is_a
end
Now, here's the test code that elicits the error:
Lua Code:
local s = Slot(1,1)
DEFAULT_CHAT_FRAME:AddMessage( s:is_a() )
It fails with the message shown above. Both function and property work as expected in the base class.
Any thoughts?