Project

General

Profile

=begin
h1. #Hash Iteration
This works in Ruby 1.8, Ruby 1.9.1 but does not work in Ruby 1.9.2

h = {'a' => 1, 'b' => 2, 'c' => 3}
p h
h.each_key do |k|
p k
if k == 'c'
h['d'] = 4
end
end
p h

This affects the dbi gem and the pg gem so it will affect all the postgresql users out there that work with Ruby. Ugh. Not nice.

This commit

You can fix the dbi-gem for Ruby 1.9.1 with these lines:

  • h.each_key do |k|
  • h.keys.each do |k|

Also see: http://dev.ywesee.com/wiki.php/Masa/20110121-setup-ramaze#Hash
=end