Collections always return results on an new instance of its own #species.
That is fabulous to me. It is what's desired most times.
With that in mind, if you expected a bag or something else, you should convert (asXXX) before the collect.
Cheers
r.
From: pharo-project-bounces@lists.gforge.inria.fr [mailto:pharo-project-bounces@lists.gforge.inria.fr] On Behalf Of Clara Allende
Sent: 27 October 2011 14:15
To: Pharo-project@lists.gforge.inria.fr
Subject: [Pharo-project] aSet collect: answers aSet??
Hi guys..
This morning some students came with an exercise like this:
(Set with: 1 with: 2 with:3 with:4 with:5) collect:[:e | e even]. a Set(false true)
But they don't want to get aSet, (regardless this particular example doesn't make sense)... the question is, why if I send collect: to aSet I get aSet and not aBag? What happens if I *want* repeated elements after the transformation? :( And when did this behavior change?
--
"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