Syntax

Swift String Interpolation Syntax

In Swift, string interpolation: inserts values into a string — "Total: \(total)"

Quick Answer

Syntax
"Total: \(total)"
SwiftSyntax

String Interpolation

Code example
"Total: \(total)"

Inserts values into a string.

Learn More

How to string interpolation in Swift

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

Swift String Interpolation Syntax

Use "Total: \(total)".

Related Syntax References

Frequently asked questions

What is the Swift syntax for string interpolation?

Use this pattern: "Total: \(total)"

Can I copy this Swift code example?

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

Is this Swift syntax different on Mac or Windows?

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

Official source · How we verify