Ok, but this means I have to worry of the receiver's class before I send collect:, so as I don't fuck it all up.... and I don't want to think about that!!! See, if I want the collection of grades of the students, I would like to do this:
On 27.10.2011 15:40, Clara Allende wrote:The consistency rule to remember for #collect:/#select:/#reject: is that they will return a collection of the receiver's species.
I know, but our students don't :) So they ran into problems because the message send didn't answer what they were specting.... �because it makes sense that if I want to transform the objects in my collection, I might get repeated objects... Maybe I'm not thinking in terms of consistency, I'm just putting myself on student's shoes :P
#collect:as: was added as a general answer to the situation your students ran into :)
set := Set withAll: #(1 2 3 4 5 6 7 8).
result := set collect: #even as: Bag.
Cheers,
Henry
"Most good programmers do programming not because they expect to get paid or get adulation by the public, but because it is fun to program."
Linus Torvalds