Interpolating Variables in Double-Quoted Strings : Interpolating « Language Basics « Ruby






Interpolating Variables in Double-Quoted Strings



temperature = 36

puts "The temperature is " + String(temperature) + "."

puts "The temperature is #{temperature}."

 








Related examples in the same category

1.Interpolation
2.Number value Interpolation
3.The #{100 * 5} interpolates the result of 100 * 5 (500) into the string at that position
4.You can interpolate strings too
5.Constant Interpolation
6.Call integer.to_s and Interpolation
7.Use string method in interpolation
8.Using expression substitution
9.Add extra # sign to interpolation
10.Compare string after interpolation
11.Put class into interpolation block
12.Do a calculation in interpolation block
13.Escape theinterpolation string
14.Interpolation in Here document