convert hash to string : Convert to String « Hash « Ruby






convert hash to string


{:a=>1, :b=>2}.to_s    # => "a1b2" in Ruby 1.8; "{:a=>1, :b=>2}" in 1.9
{:a=>1, :b=>2}.inspect # => "{:a=>1, :b=>2}" for both versions

 

Related examples in the same category

1.Output hash to string then remove the key and gsub