to_s to convert a number into a string
You will get an error with the following code.
The error message says that
no implicit conversion of Integer into String.
In simple english, Ruby is saying that we cannot add an integer with a string. This makes sense. We should be able to add two numbers. We should be able to add two strings. However we should not be allowed to add a string and a number.
To solve this problem, we need to convert
the integer into a string.
Ruby provides method
to_s to convert an integer to string.
to_s stands for “to string”.
to_s on 24 to make it a string.