arr_odd=[];
arr_even=[];
arr.each {|x| a.index(x).even? ? arr_even << x : arr_odd << x}


On Wed, Mar 5, 2014 at 11:34 AM, Selvag Ruby <lists / ruby-forum.com> wrote:

> It's just for understanding the concept. We know more built-in methods
> of Array Class. If I need to separate the item(s) of a list by even
> numbered index and odd numbered index.
>
> arr=[12,11,'a',:true,300,-22,{},[],'n-1','n']
>
> code want to produces,
>
> arr_odd=[11,:true,-22,[],'n']
> arr_even=[12,'a',300,{},'n-1']
>
> --
> Posted via http://www.ruby-forum.com/.
>