Forum: Ruby Re: I have some problem with convert to symbol, in Hash obje

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Peña, Botp (Guest)
on 2006-04-27 13:27
(Received via mailing list)

# I want to convert "name" to :symbol
#   "name"=>"Ilyas store"   ---> :name => "Ilyas store"

sample only,

irb(main):039:0* h1={"fax"=>"80233923293", "name"=>"Ilyas store"}
=> {"name"=>"Ilyas store", "fax"=>"80233923293"}
irb(main):045:0* h2 = {}
irb(main):046:0> h1.each do |k,v|
irb(main):048:1>    h2[k.to_sym] = v
irb(main):049:1> end
irb(main):054:0> h2
=> {:fax=>"80233923293", :name=>"Ilyas store"}

kind regards -botp
This topic is locked and can not be replied to.