Hi,

2014-03-05 15:34 GMT+09:00 Selvag Ruby <lists / ruby-forum.com>:
> 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']
>
You can do something like this:
arr_even,arr_odd=arr.each_with_index.partition{|v|v[1].even?}.map{|v|v.map{|v|v[0]}}

Regards,
Park Heesob