On Thu, Oct 27, 2011 at 3:26 PM, Diaz Trepat, Ramiro <ramiro.diaz.trepat@jpmorgan.com> wrote:

Collections always return results on an new instance of its own #species.�

That is fabulous to me.� It is what's desired most times.



But also for #collect:� ?�� I think I see the point of Carla.� Do you see a relation between the receiver collection class and the collection class of what you want to collect?�� I don't see a relation at all. So why would returning the same would help here?�� Again, I am ONLY talking about #collect.
Wouldn't be better to always answer, say, ORderedCollection (I guess it is quite common and usuful) and then only is desired something different use #asSomething or even collect:as:�� ?

Cheers

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.




--
Mariano
http://marianopeck.wordpress.com