From: Martin DeMello Date: 2006-12-07T03:12:23+09:00 Subject: Re: join_with On 12/6/06, Logan Capaldo wrote: > > > > hex_ip.scan(/../).join_with('.') {|i| i.hex} > hex_ip.scan(/../).map {|i| i.hex}.join('.') > Hey look, the long way is even shorter! Do you just want to conflate I knew someone would say that :) > these two because theres room in the interface? That seems like a silly > reason. It would also set a bad precendent. (Well hey, delete doesn't > take a block, lets add one and pass the deleted item in...) No, more because map-then-join is a very common pattern, and the complementary argument lists let us combine them neatly. html_table = ary.jmap("\n") {|col| col.jmap {|cell| "#{cell}"} } as opposed to html_table = ary.map {|col| col.jmap {|cell| "#{cell}"}.join }.join("\n") The benefit is that the block is the last argument to what is conceptually a single operation. martin