Consider the following code:
x = 10
y = 20
puts "#{x} + #{y} = #{x + y}"
You can embed expressions and logic directly into strings.
This process is called interpolation.
String interpolation can insert the result of an expression into a string literal.
To interpolate within a string, place the expression within #{ and } symbols.
puts "100 * 5 = #{100 * 5}"
The #{100 * 5} section interpolates the result of 100 * 5 into the string at that position.
You can interpolate other strings, too:
x = "cat" puts "The #{x} in the hat" puts "It's a #{"nice " * 2}world"
Interpolation works within strings used in assignments:
my_string = "It's a #{"nice " * 3}world" puts my_string