0Pricing
Ruby Academy · Lesson

Interpolation and Formatting

Build strings with values.

String Interpolation

Interpolation lets you embed Ruby expressions inside a double-quoted string using #{ }. The expression is evaluated and inserted as text.

name = "Ada"
puts "Hello, #{name}!"

Single vs Double Quotes

Interpolation only works in double-quoted strings. Single quotes treat #{ } as literal text.

x = 5
puts "value is #{x}"
puts 'value is #{x}'

All lessons in this course

  1. String Basics and Methods
  2. Interpolation and Formatting
  3. Searching and Replacing
  4. Splitting and Joining
← Back to Ruby Academy