Function Parameter Bug

Here is a test app I made:

-- Bug

Cc = class()

function Cc:init(x,t,c,tr)
    -- you can accept and set parameters here
    print(x+t+c+tr)
end

-- Use this function to perform your initial setup
function setup()
    print("Hello World!")
    b = Cc()
    b:init(28,372,2,2938)
end


When I run it it displays an error:

attempt to perform arithmetic on a nil value (local x)

I really don’t know what is happening O_o


Cc = class()

function Cc:init(x,t,c,tr)
    -- you can accept and set parameters here
    print(x+t+c+tr)
end

-- Use this function to perform your initial setup
function setup()
    print("Hello World!")
    b = Cc(28,372,2,2938)
    -- this is how you init an instance of a class, you don't need to call the 'init' function, it does that automaticly
end

edited code and put explanation in comment :slight_smile: hope this helped

Thanks! :slight_smile: