Re: Update to Array#join
Ryan Davis <[email protected]> Thu, 15 Feb 2007 11:41:59 -0800
| Newsgroups | gmane.comp.lang.ruby.documentation |
|---|---|
| Message-ID | <[email protected]> |
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.