T
Todd S.
I'm to to ruby...
Currently, I'm stuck in a situation where I'm changing values I'm not
intending to and I don't know how to correct it.
I have... A class "Model" and a class "DataObject". The "Data Object"
class has a method which takes in a "Model" and returns a new "Model".
The problem is, my "generate_new_model" method is altering the input
"Model" object.
The below show basically what I've done to create the objects. Somehow
when I define a new "Model" for output and set it's values to the source
model's values, when I change the outputModel values it alters the
source model.
What am I doing wrong?
@myModel = Model.new
@myData = DataObject.new
newModel = @myData.generate_new_model(@myModel)
def generate_new_model(modelSource)
outputModel = Model.new
outputModel = modelSource
outputModel.values = "new values"
outputModel
end
Currently, I'm stuck in a situation where I'm changing values I'm not
intending to and I don't know how to correct it.
I have... A class "Model" and a class "DataObject". The "Data Object"
class has a method which takes in a "Model" and returns a new "Model".
The problem is, my "generate_new_model" method is altering the input
"Model" object.
The below show basically what I've done to create the objects. Somehow
when I define a new "Model" for output and set it's values to the source
model's values, when I change the outputModel values it alters the
source model.
What am I doing wrong?
@myModel = Model.new
@myData = DataObject.new
newModel = @myData.generate_new_model(@myModel)
def generate_new_model(modelSource)
outputModel = Model.new
outputModel = modelSource
outputModel.values = "new values"
outputModel
end