On 27.10.2011 15:40, Clara Allende wrote:
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
The consistency rule to remember for #collect:/#select:/#reject: is that
they will return a collection of the receiver's species.
#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