Converts the keys of the hash to symbols.
{ 'one' => 1, 'two' => 2 }.symbolize_keys #=> { :one => 1, :two => 2 } { 1 => "a" }.symbolize_keys #=> { 1 => "a" }
Returns:
a copy of the original hash with its keys converted to symbols. Leave nonconvertible keys untouched when symbolizing keys.
10 11 12
# File 'lib/powerpack/hash/symbolize_keys.rb', line 10 def symbolize_keys Hash[map { |(k, v)| [(k.to_sym rescue k), v] }] end