From: William Morgan Date: 2005-07-07T01:05:35+09:00 Subject: Re: Inheriting Array and slice() behaviour Excerpts from Sylvain Joyeux's mail of 6 Jul 2005 (EDT): > I have a class inheriting Array, and I expected slice() and [] > to return Array objects. Unfortunately [...] > Moreover, since my Expression class has instance variables, the instance > produced by slice() does not have it anymore (which is bad) It looks like [], slice and slice! methods create a new instance of the objects class as the return value, but don't initialize it---so any instance variables will be nil (rb_ary_subseq). I agree that this is weird. > I wokarounded this by using Delegator What return type do you want? Arrays or Expressions? You can force return values back to Arrays with #to_a, or manually make Expressions with something like y = Expression.new(x.slice(1..5).to_a) -- William