7/7 Why do we have do .to_s


Why do we have to do

frequencies.each do |word, count|
    puts word + " " + count.to_s

Why doesn't puts word + " " + count work?


Because our frequencies hash has values of type Integer. That's why we use the to_s method to convert them to strings so that puts can display them normally.

We don't have this problem with the keys because they're already strings.


why did we have to convert the value to string ?


Thanks for this answer