Loop hash with interpolation
transform_results = { 4 => 8, 9 => 9, 10 => 6, 2 => 7, 6 => 5 }
transform_results.each { |x, y| puts "f(#{x})=#{y}: difference #{y-x}" }
# f(9)=9: difference 0
# f(6)=5: difference -1
# f(10)=6: difference -4
# f(4)=8: difference 4
# f(2)=7: difference 5
Related examples in the same category