From: "David A. Black" Date: 2009-06-23T04:46:08+09:00 Subject: Re: map shall not return an Enumerator ( was re guru help ) --1926193751-654381357-1245699955=:26130 Content-Type: MULTIPART/MIXED; BOUNDARY="1926193751-654381357-1245699955=:26130" This message is in MIME format. The first part should be readable text, while the remaining parts are likely unreadable without MIME-aware tools. --1926193751-654381357-1245699955=:26130 Content-Type: TEXT/PLAIN; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 8BIT Hi -- On Tue, 23 Jun 2009, Robert Dober wrote: > On Mon, Jun 22, 2009 at 9:13 PM, David A. Black wrote: >> Hi -- >> >> On Tue, 23 Jun 2009, Robert Dober wrote: >> >>> On Mon, Jun 22, 2009 at 2:52 PM, Brian Candler wrote: >>>> >>>> Robert Dober wrote: >>>> That I dislike very much. What you want is to run a 'join' operation on >>>> *each member* of the collection, but that looks like running a .map.join >>>> on the *whole* collection. From that point of view, >>>> >>>> �coll.map { |c| c.join(",") } >>>> >>>> expresses very clearly what you're doing. >>> >>> I agree with you, that this is confusing at first sight, but actually >>> coll.map.join instead of coll.join does not make any sense at all. >>> My corollary is: >>> Any method sent to map makes only sense to be sent to the elements of >>> the collection and not >>> to the collection itself because that would make map a NOP. >> >> You don't send a message to map, though. map is a method; messages go >> to objects. Methods can be provided with code blocks, but that's part >> of the method call. Once the next dot appears, the method call is over >> and the message goes to the resulting object. > > You are very harsh with me, I believed this was clear in the context ;) Not entirely :-) It sounded like you were saying that something like array.map.join(",") should be the same as array.map {|e| e.join(",") }, which I think is like having a method/message being sent to another method/message. > yeah this is an edge case, but why should I do map.with_index when I > mean to_enum.with_index? I agree that it's a bit cryptic. David -- David A. Black / Ruby Power and Light, LLC Ruby/Rails consulting & training: http://www.rubypal.com Now available: The Well-Grounded Rubyist (http://manning.com/black2) "Ruby 1.9: What You Need To Know" Envycasts with David A. Black http://www.envycasts.com --1926193751-654381357-1245699955=:26130-- --1926193751-654381357-1245699955=:26130--