String interpolation with calculation : Convert to String « Number « Ruby






String interpolation with calculation


number = 5

puts "The number prior to #{number} is #{number-1}."

 








Related examples in the same category

1.Integer passed into a string with interpolation
2.Substituting Variables Into Strings
3.constant value interpolation
4.String interpolation with method call
5.Convert float to string
6.Convert integer to string by parameter
7.Convert string to integer with error