From: Florian Gross Date: 2004-04-24T14:49:09+09:00 Subject: Re: Array to Hash Ara.T.Howard wrote: > On Sat, 24 Apr 2004 nobu.nokada@softhome.net wrote: >>module Enumerable >> def to_h >> inject({}) {|h, (k, v)| h[k] = v; h} > > ^^^^^^ > ^^^^^^ > ^^^^^^ > what's this? > inject will get yielded the current state of the result Hash and a new [key, value] Array. The () syntax lets you access the components of that Array directly through the variables you use. This is similar to this assignment: pair, (key, value) = ["one", 1], ["two", 2] pair # => ["one", 1] key # => "two" value # => 2 This is also explained in the Pickaxe book: http://www.rubycentral.com/book/tut_expressions.html#UD Regards, Florian Gross