7/7 Why do we have do .to_s


#1

Why do we have to do

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

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


#2

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.


#3

why did we have to convert the value to string ?


#4

Thanks for this answer