Hi --

On Tue, 3 Jun 2008, ara.t.howard wrote:

>
> On Jun 2, 2008, at 7:13 PM, David A. Black wrote:
>
>> 'm just wondering whether it would make more sense for Set to have a
>> #map method that returned a set, rather than an array, as long as that
>> behavior is considered meaningful (as it appears to be since that's
>> how Set#map! is working). Otherwise that aspect of the map/map!
>> distinction seems kind of arbitrary.
>
> it doesn't seem arbitrary:
>
> cfp:~ > ruby19 -r set -e' p Set.instance_methods(false).grep(/map/) '
> [:map!]

I'm not sure what you mean. I didn't suggest there was no Set#map!
method. (It's that very method that I was talking about.)

> set gains #map from Enumerable.

Right; that's also my point of departure.

> if map did not return array it would remove 
> the ability to rely on interface polymorphism in ruby methods accepting 
> enumerables - which is something most of us take for granted by now.  to me 
> it seems more strange that 'map!' returns a set - rather than a 'changed' 
> status - but not overly so as i expect to have to use bang methods carefully 
> after reading the docs...

I guess it comes down to whether or not the conversion to array is
"greedy" -- that is, whether it happens whenever it *can* happen, or
just whenever it *must* happen.


David

-- 
Rails training from David A. Black and Ruby Power and Light:
   INTRO TO RAILS         June 9-12            Berlin
   ADVANCING WITH RAILS   June 16-19           Berlin
See http://www.rubypal.com for details and updates!