Otherwise, it needs to be
h = {:a => 1, :b => 2.2}
h.each_with_index do |pair, i|
k = pair[0]; v = pair[1]
p k, v, i
end
and setting the k and v this way seems a bit clumsy. Can it be simpler or something like
h.each_with_index do |[k,v], i|
?
In fact, yes! Use parentheses: