From: Sam Roberts Date: 2004-03-18T08:10:54+09:00 Subject: Re: Can subclass have superclass method return instance of subclass Quoteing cjh-nospam@nospaManagesoft.com, on Thu, Mar 18, 2004 at 07:20:54AM +0900: > walter@mwsewall.com wrote: > >Ruby has such beautiful Array functionality that I find I always end > >up wanting to use it in my customized subclasses. > > Can't you get much of what you want my mixing-in Enumerable? Array has lots of useful apis that Enumerable doesn't. I suspect, though, that you could define a core set of "Array" operations, and then write an Arrayable module that when you mix-in, gives you all the other Array methods (&, *, slice, ...) that Enumerable doesn't have. Maybe you could even write Arrayable so it is entirely implemented with each(), but I think it wouldn't be very efficient, imagine having to implment [] by doing each_with_index() until you found the required index! Cheers, Sam