I have a problem with classes. I got below error: Attempt to index local 'self' (a nil value) When I call the getter method of below class. Item.lua file:
require "classlib"
Item = class("Item")
function Item:__init()
self.interval = 1
end
function Item:getInterval()
return self.interval
end
I'm calling this getter function like this:
dofile("../src/item.lua")
item = Item()
function test_item()
assert_equal(1, item.getInterval())
end
What's the problem here?
Kind regards...
item:getInterval()
instead ofitem.getInterval()
insidetest_item()
. – Omri Barelclass()
call. And @OmriBarel should probably post an answer, instead of a comment... :-) – PhiLho