Forum: Ruby what would be the easiest/fastest way to convert Hash keys

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Jarmo P. (Guest)
on 2009-01-07 09:51
Hello.

I was wondering, what would be the easiest and fastest way to convert
Hash keys from Symbol objects to String?

I came up with something like this, but I think that maybe there's some
better Ruby-way to do it:

tmp = {}
h.each_pair {|k, v| tmp[k.to_s] = v}
h = tmp
This topic is locked and can not be replied to.