I wasn’t working with ruby 1.8.7 and recently I was surprised that:
{:k => 30}.to_s #=> "k30"
Is there ready to use fix to convert hash to string for ruby 1.8.7 to make it look like:
{:k => 30}.to_s #=> "{:k=>30}"
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
hash.to_shas indeed been changed from1.8.7to1.9.3.In
1.8.7, (ref: http://ruby-doc.org/core-1.8.7/Hash.html#method-i-to_s):In
1.9.3, (ref: http://www.ruby-doc.org/core-1.9.3/Hash.html#method-i-to_s)You could monkey-patch Hash class in 1.8.7 to do the same locally with the following:
Before monkey-patching:
Monkey-patching & after: