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
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
�
This email is confidential and subject to important disclaimers and conditions including on offers for the purchase or sale of securities, accuracy and completeness of information, viruses, confidentiality, legal privilege, and legal entity disclaimers, available at http://www.jpmorgan.com/pages/disclosures/email.
"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