From: Eero Saynatkari Date: 2006-08-30T09:23:18+09:00 Subject: Re: Hash#inject argument syntax Brian Buckley wrote: > The code below works but I do not understand the "(key, value)" > parenthesis syntax. I have not seen it before. Could someone > explain? > > --Brian > > (from Rails' active_support) > class Hash > def symbolize_keys > inject({}) do |options, (key, value)| Hash#each, as you may know, actually produces an Array of Arrays (key-value pairs). Here what is being passed is actually one of those pairs--the parenthesised syntax uses Ruby's assignment rules and splats the Array to two distinct variables. Consider it the same as: key, value = ['key', 'value'] > options[key.to_sym] = value > options > end > end > end > (above code from Rails' active_support) -- Posted via http://www.ruby-forum.com/.