From: Intransition Date: 2010-04-10T03:53:28+09:00 Subject: Re: Is it possible, a fully general Enumerable#recursive ? On Apr 9, 2:03 pm, Robert Dober wrote: > On Thu, Apr 8, 2010 at 5:51 AM, David Masover wrote: > > On Wednesday 07 April 2010 04:49:15 pm Intransition wrote: > > > >> This works for #each and #map but not #sort. > > > #sort isn't a method of Enumerable, it's a method of Array. > > ruby-1.9.1-p378 > Enumerable.instance_methods.grep /sort/ >  => [:sort, :sort_by] > However you will need to define #<=>  on the return value of recursive. Yep. That's trick b/c comparing and array or other enumerable to a non enumerable raises an error. So sorting with this is probably out of the question. On a side note, I am not so sure that raising an error is best. Why not just assume that too non-comparable things are equal?