From: Jason Lillywhite [mailto:jason.lillywhite / gmail.com] 
# However, iterating over a hash is confusing me. Here is 
# a simple example:
# 
# hash = 
# [[:diameter, 45], [:id, 2]].inject({}) do |result, element|
#   result[element.first] = element.last
#   result
# end
# 
# can someone help me understand better what exactly is 
# happening on each 
# iteration?
# hash(i=1) = ??
# hash(i=2) = ??

initial:
  result = {}

iter 1:
  result[:diameter] = 45

iter 2: 
  result[:id] = 2


i think the confusion stems around the lonely line containing "result". You'll need that because inject will retrieve and use the value of the code block as the next "result". (try testing it by removing the "result" line :)

it is in unique cases like these that i find inject not too intuitive ;)

i might be better off with,

hash = {}
[[:diameter, 45], [:id, 2]].each do |k,v|
   hash[k] = v
end

or

hash = Hash[ * [[:diameter, 45], [:id, 2]] . flatten ]