Creating an Array of Hashes in Ruby
Monday, August 25th, 2008 •
2 comments •
Filed Under
I just made a simple mistake which I figure would be good share with anybody new-ish to Ruby. I wrote the following code to create an array of hashes and fill in some values. Can you guess what the output is?
#!/usr/bin/env ruby
testArray = Array.new(5, Hash.new)
0.upto(4) do |i|
testArray[i][:value] = i
end
0.upto(4) do |i|
[…]

