Andrew Timberlake wrote:

>> h = {:a => :b, 2 => 4, :g=> 6 }
>> Posted via http://www.ruby-forum.com/.
>>
>>
> 
> new_hash = {}
> hash.each { |k,v| new_hash[k.to_sym] = v }
> h.each { |k,v| new_hash[k.to_sym] = v }
> 

if we have nubers in the hash that we'll be converted to nil with to_sym 
:
hash = {:a => :b, 2 => 3, "g"=> 5 }
=> {2=>3, "g"=>5, :a=>:b}
h = {:a => :b, 2 => 4, :g=> 6 }
=> {:g=>6, 2=>4, :a=>:b}

new_hash = {}
=> {}
hash.each { |k,v| new_hash[k.to_sym] = v }
=> {2=>3, "g"=>5, :a=>:b}
h.each { |k,v| new_hash[k.to_sym] = v }
=> {:g=>6, 2=>4, :a=>:b}
hash
=> {2=>3, "g"=>5, :a=>:b}
h
=> {:g=>6, 2=>4, :a=>:b}
new_hash
=> {:g=>6, nil=>4, :a=>:b}

And I can't control the inputs in the hash, so I must treat that by 
myself
-- 
Posted via http://www.ruby-forum.com/.