Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug] lib.class private table returns not expected value #549

Closed
deFuzz77 opened this issue Apr 18, 2024 · 0 comments
Closed

[Bug] lib.class private table returns not expected value #549

deFuzz77 opened this issue Apr 18, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@deFuzz77
Copy link
Contributor

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.

@deFuzz77 deFuzz77 added the bug Something isn't working label Apr 18, 2024
@deFuzz77 deFuzz77 changed the title [Bug] [Bug] lib.class private table returns not expected value Apr 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant