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
#########################################################
vor-lord:/tmp> ruby r.rb
VERSION: 1.7.2
PLATFORM: i386-linux
items is of type Array
1 = bar, 2 = 56
items is of type Array
1 = foo, 2 = 3
vor-lord:/tmp> /usr/bin/ruby r.rb
VERSION: 1.8.0
PLATFORM: i386-linux-gnu
items is of type Array
1 = foo, 2 = 3
items is of type Array
1 = bar, 2 = 56
linux4:vor-lord/tmp> /opt/ictools/64bit/bin/ruby r.rb
VERSION: 1.8.1
PLATFORM: x86_64-linux-gnu
items is of type Array
1 = foo3, 2 =
items is of type Array
1 = bar56, 2 =
linux4:vor-lord/tmp> /usr/bin/ruby r.rb
VERSION: 1.6.8
PLATFORM: x86_64-linux-gnu
items is of type Array
1 = bar, 2 = 56
items is of type Array
1 = foo, 2 = 3
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?