Return hash with modified values in Ruby
Posted
by smotchkkiss
on Stack Overflow
See other posts from Stack Overflow
or by smotchkkiss
Published on 2010-04-03T18:45:09Z
Indexed on
2010/04/03
18:53 UTC
Read the original article
Hit count: 315
I'm trying this:
{:id => 5, :foos => [1,2,3]}.each {|k,v| v.to_s}
But that's returning this:
{:id=>5, :foos=>[1, 2, 3]}
I'd like to see this:
{:id=>"5", :foos=>"[1, 2, 3]"}
I've also tried variations of Hash#collect
and Hash#map
. Any ideas?
© Stack Overflow or respective owner