From: Brian Candler Date: 2009-06-23T23:47:49+09:00 Subject: Re: map shall not return an Enumerator ( was re guru help ) Robert Dober wrote: > On Tue, Jun 23, 2009 at 3:32 AM, David A. Black > wrote: > > > It would buy me > coll.send_to_elements( :+ , 42 ) > coll.send_to_elements.join( ", ") > versus > coll.map{ |x| x + 42 } > coll.map{ |x| x.join( ", ") } > it is not so much about typing (although nobody would forbid aliasing > #send_to_elements) but about readability. The first I find pretty much unreadable. Send a message to each element, but do what with the result? Is it like inject perhaps? The second is obvious. Iterate over the collection, mapping each element |x| to x + 42 (or whatever), and storing in a new collection. Anyway, nobody stops you defining Enumerable#send_to_elements if you like it, without having to inflict it on the rest of us. -- Posted via http://www.ruby-forum.com/.