Reputation: 97
Indeed it is within the framework of a research. I'm trying to generate random values for the instance variables of an X object. So when instantiating the object, I replace the parameters of the object initialization method with the values that are generated.
So, I manage to retrieve instance variables, generate random values. The problem now is how to replace the arguments of the initialization method with the generated values?
we have my Person class
Object subclass: #Person
instanceVariableNames: 'name lastName birthDate'
classVariableNames: ''
package: 'Moi'
the method that i use to initialize a person is:
withName: aName andBirthDate: aBirthDate andLastName: aLastName
name:= aName.
lastName:= aLastName.
birthDate:= aBirthDate
For example I have the method
Person>>#withName:aName andBirthDate:aBirthDate andLastName:aLasatName
and I have the following values: "toto", "13 sept 2022" and "tata"
How to override or rebuild method like this
Person>>#withName:'toto' andBirthDate:'13 Sep 2022'andLastName:'tata'?
```bri
the Person class is an example. Instead of the Person class, we can have Point, Car or any other class.
Upvotes: 0
Views: 225
Reputation: 2210
No, you will need to call the constructor and break out the arguments:
Person
withName: (list at: 1)
lastName: (list at: 2)
birthDay: (list at: 3)
Upvotes: 1