Download Firefox: WindowsMac OS X
logo       
Google Custom Search
    AddThis Social Bookmark Button
-->

Re: Update to Array#join: msg#00007

Subject: Re: Update to Array#join

On Feb 15, 2007, at 6:15 AM, Gary Wright wrote:


On Feb 15, 2007, at 5:35 AM, Ryan Davis wrote:
try something like:

Every sub-array is converted to a string by applying join recursively, essentially flattening the array.

I thought of this also but it suggests to me that #join itself is
called on the sub-array, which is not true.  The recursive algorithm
is implemented entirely within Array#join.

No, it IS called recursively. rb_ary_join calls rb_protect_inspect (inspect_join, ...) which in turn calls rb_ary_join.

I considered this detail important because if someone had defined
#join for the subarray (as a singleton method) then they might think
they could 'override' the behavior of #join for that element of the
array.

It is called directly (not via rb_funcall) as is everything else in core. This is to be expected.

Anyway, that is why I avoided any reference to #flatten and to #join.

I think your avoidance of trying to be unclear has caused your description (while still better than the original) to be unclear.





<Prev in Thread] Current Thread [Next in Thread>