Syntax

Kotlin String Template Syntax

In Kotlin, string template: inserts values into a string — "Hi $name, total ${a + b}"

Quick Answer

Syntax
"Hi $name, total ${a + b}"
KotlinSyntax

String Template

Code example
"Hi $name, total ${a + b}"

Inserts values into a string.

Learn More

How to string template in Kotlin

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

Kotlin String Template Syntax

Use "Hi $name, total ${a + b}".

Related Syntax References

Frequently asked questions

What is the Kotlin syntax for string template?

Use this pattern: "Hi $name, total ${a + b}"

Can I copy this Kotlin code example?

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

Is this Kotlin syntax different on Mac or Windows?

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

Official source · How we verify