Syntax

Ruby String Interpolation Syntax

In Ruby, string interpolation: inserts values into a string — "Hi #{name}"

Quick Answer

Syntax
"Hi #{name}"
RubySyntax

String Interpolation

Code example
"Hi #{name}"

Inserts values into a string.

Learn More

How to string interpolation in Ruby

  1. Open your Ruby file or editor.
  2. Copy the example, then replace its sample names and values for your code.

Ruby String Interpolation Syntax

Use "Hi #{name}".

Related Syntax References

Frequently asked questions

What is the Ruby syntax for string interpolation?

Use this pattern: "Hi #{name}"

Can I copy this Ruby code example?

Yes. Use Copy code and adapt the example to your program.

Is this Ruby syntax different on Mac or Windows?

No. The language syntax is the same across operating systems.

Official source · How we verify