Code should be as declarative as possible (that usually means in functional style): def transform special_values = {"1" => true, "0" => false} Hash[preferences.map { |k, v| [k.to_sym, special_values.fetch(v, v)] }] end However, `Hash[...]` is very ugly and I prefer a more OOP approach with [Enumerable#mash][1], so I'd really write `preferences.mash { |k, v| [k.to_sym, special_values.fetch(v, v)] }`. [1]: http://rdoc.info/github/rubyworks/facets/master/Enumerable#graph-instance_method