Pharo initialize an object with an OrderedCollection

Viewed 34

I have another problem in pharo. I have a Class Person who have three instance variables(name,lasteName and birthDay). I initialize the class like this( withName:aName lastName: lastname bithDay: birthday). Now I have an OrderedCollection that contain three values generated randomly like: #(#185,#632,#'13 September 1976').

I want to create a new Person with the values in the orderedCollection. could it be possible to do like this

|aPerson|
(list size) do:[:i |
aPerson := Person new:i]
1 Answers

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)
Related