From: Florian Gross Date: 2004-09-18T19:09:45+09:00 Subject: Re: Accessing Hash elements in sorted order? Gavin Sinclair wrote: >>cgi.params.sort.each do |(key, value)| >> puts "#{key}=#{value}" >>end > > cgi.params.sort.each do |key, value| > > works as well. Do the parentheses add anything -- like > future-proofing? I think it is most clear when using parentheses. (Because it looks exactly like the array structure: [number, [english, german]]) Personally, I would like the x = 1, 2 case to be equivalent to x, = 1, 2. (It would allow blocks to reject arguments easily. E.g. #each could yield(item, index) and if you were to do |item| it would work correctly.) Here are some possible styles. Maybe you will prefer an other one than me: number_words = [ [1, %w{one eins}], [2, %w{two zwei}], [3, %w{three drei}] ] number_words.each do |(number, (english, german))| puts "#{number} is '#{english}' in English and " + "'#{german}' in German" end number_words.each do |number, words| # I think this should be *words for clarity, but in the # rhs of the argument list assignment there is no splash. (AFAIK) english, german = words ... end number_words.each do |number, (english, german)| # Combined ... end Hm, I guess it's mostly an "explicit is easier to understand than implicit" decision for me. Regards, Florian Gross