From: Florian Gross Date: 2003-10-30T04:59:57+09:00 Subject: Re: [RCR] #inject, #partition expand array if arity > 2 Moin! Simon Strandgaard wrote: > It would be awesome, if #inject could do splitting when arity > 2. > For instance converting an array of pairs into a hash (arity==3): > x=[["name", "john"], ["age", 20]] > p x.inject({}){|h,k,v|h[k]=v;h} > #=> {"name"=>"john", "age"=>20} This is already possible with a built-in ruby feature: x=[["name", "john"], ["age", 20]] x.inject({}) { |h, (k,v)| h[k]=v; h } # => {"name"=>"john", "age"=>20} Regards, Florian Gross