From: "Mehr, Assaph (Assaph)" Date: 2004-08-20T12:53:16+09:00 Subject: Re: splat behavior with different versions of ruby > This is probably common knowledge, but the references I could find where > annotated only in Japanese so I'm just not sure what is happening here: > ######################################################### > #!/usr/bin/env ruby > puts "VERSION: #{RUBY_VERSION}" > puts "PLATFORM: #{RUBY_PLATFORM}" > h = { 'foo'=>3, 'bar'=>56 } > h.each do |*items| > puts "items is of type #{items.class}" > puts "1 = #{items[0]}, 2 = #{items[1]}" > end > ######################################################### > So out of 1.6.8, 1.7.2, 1.8.0, and 1.8.1, only 1.8.1 exhibits the > behavior that I find counterintuitive. Is this the way it is supposed > to work? If so, what is the rationale? 1.8.2 behaves the same as 1.8.1. Works as expected without the splat: c:\>ruby puts "VERSION: #{RUBY_VERSION}" puts "PLATFORM: #{RUBY_PLATFORM}" h = { 'foo'=>3, 'bar'=>56 } h.each do |items| puts "items is of type #{items.class}" puts "1 = #{items[0]}, 2 = #{items[1]}" end ^Z VERSION: 1.8.2 PLATFORM: i386-mswin32 items is of type Array 1 = foo, 2 = 3 items is of type Array 1 = bar, 2 = 56