Swift: does a parameter in a class change to nil every time the class is called?

I have a class with a parameter in the form

class class_name: Codable {
    var array_name = []
}

Running the code, I see I can add numbers in the array. But when I get the array in another function it says it is empty. I do it with:

let new_class = class_name()

Can it happen that the value gets reseted for calling the class again?

That was the problem. I could solve it using the variable of one function in the other function. Instead of doing let new_clas = class_name() again, I just did this in the first function and sent the object to the second one

There is some confusion:

When you call:

let new_class = class_name()

You do not call the instance, you create a new one. So you don't reset an existing one, you set a new one, with empty array (not nil, just empty).

I you want to use the same instance o class_name, you have to declare a var to hold the instance. Or send a reference o the instance, as you did.

Swift: does a parameter in a class change to nil every time the class is called?
 
 
Q