On Mon, Jun 2, 2008 at 9:19 PM, Yukihiro Matsumoto <matz / ruby-lang.org> wrote:
>
> Do you want to make a new rule that map should return the object of
> the same class as the receiver?  If so, what do you think collect
> (currently map's alias) should return?

I'm personally a fan of #collect returning an array, and #map
returning an object of the same class as the receiver. If not (since
it would break a lot of code), perhaps something like #smap (for
structure-preserving map) that each class has to define for itself,
rather than inheriting from Enumerable.

I also feel a #smap should be 'deep', calling smap on any of the
collection's children that respond to it. And that non-collections
like String should "play along" by not implementing it (String#each
was a great inconvenience when I was trying to define my own generic
deep-map that worked over Enumerables)

martin