From: Robert Klemme Date: 2010-04-13T00:08:24+09:00 Subject: Re: Is it possible, a fully general Enumerable#recursive ? 2010/4/12 Robert Dober : > On Sun, Apr 11, 2010 at 10:55 PM, Robert Klemme > wrote: >> On 04/09/2010 08:53 PM, Intransition wrote: >>> >>> On Apr 9, 2:03 pm, Robert Dober wrote: > eed to define #<=>  on the return value of recursive. >> >> Why that?  The whole point would be to sort all elements that would be >> recursively returned.  The #recursive return value would never be seen then. >  #each takes care of structure #<=> takes care of order, IOW As far as I understand the initial posting of this thread the whole point is to create "something" (aka an Enumerator) whose #each method recursively iterates through nested Enumerables. This implies that during that iteration only elements inside Enumerables are yielded which are not Enumerable. Hence there is no need to provide a generalized <=> because x.recursive.sort only ever sees those non Enumerable elements. Of course, sort only can work properly if all elements have the same type, are compare compatible or an explicit comparison block is passed to #sort. > #recursive is called from #each, or did I miss something here? Technically speaking yes, but more correct would be to say that #recursive is invoked from #recursive. (=> my implementation for an example) I don't really understand why this thread seems to be so complicated. I suspect that either I am missing something or not understanding properly, or other contributors to this thread are missing something. :-) Kind regards robert -- remember.guy do |as, often| as.you_can - without end http://blog.rubybestpractices.com/