Yes, this will throw an error in Ruby because of line 1:
>1 cars = 100
Ruby does not allow the mixing of integers and strings. So, as mentioned, you can invoke the .to_s method. Or you can interpolate the variables as you have done so with #{cars} inside double quotes.
When I read exercise 4, I thought, "I can't believe Ruby made the same mistake as Javascript!" Glad to learn this particular type of foot shooting is not possible in Ruby.
Interpolation actually calls #to_s on the object, so if object.respond_to?(:to_s) returns true, you can use use it inside #{} in any kind of string that allows interpolation.
Yes, this will throw an error in Ruby because of line 1:
>1 cars = 100
Ruby does not allow the mixing of integers and strings. So, as mentioned, you can invoke the .to_s method. Or you can interpolate the variables as you have done so with #{cars} inside double quotes.