On Wed, Sep 7, 2011 at 12:47 AM, Intransition <transfire / gmail.com> wrote:
> Is there a method out there already that does anything like this?
>
>  °ݮ𨰮 ۰۴
>  °ݮ𨰲  ۰۲ݬ ۴

I guess I would just do something like this:

class Array
  def group(*ranges)
     ranges.map { |r| values_at(r) }
   end
end

>> [0,1,2,3,4].group(0..-2, -1)
=> [[0, 1, 2, 3], [4]]
>> [0,1,2,3,4].group(0, 2..3, 4..-1)  #=> [[0], [2,3], [4]]
=> [[0], [2, 3], [4]]