[Bug] lib.class private table returns not expected value
Closed this issue · 0 comments
deFuzz77 commented
Describe the bug
I have problem with private table in lib.class, acctualy when I call method from the same method, the private table returns null.
To Reproduce
I wrote simple code to reproduce this.
local Inventory = lib.class('Inventory')
function Inventory:constructor()
self.private.items = { { name = 'bread', count = 1 }, { name = 'water', count = 2 } }
end
function Inventory:getItem(rec)
print(json.encode(self.private.items))
rec = rec or 0
if rec == 1 then return end
rec += 1
return self:getItem(rec)
end
local playerInventory = Inventory:new()
playerInventory:getItem()
--[[
returns:
--> [{"count":1,"name":"bread"},{"count":2,"name":"water"}]
--> null
]]
Expected behavior
I expected the private table return its data.