Multi-dollar String Interpolation in Kotlin

Improve $ handling in string literals

View at original site


Kotlin’s string interpolation has been a much-liked feature from the beginning, and in this video, we'll learn about how JetBrains is adding more flexibility to it with multi-dollar string interpolation.

To enable it:

  • Ensure you are using Kotlin 2.1.0 or later in your project
  • Add -Xmulti-dollar-interpolation as a compiler argument

For IDE support: Use the latest 2024.3 version of IntelliJ IDEA with K2 mode enabled (requires restart) Get more info here: https://kotlinlang.org/docs/whatsnew21.html#multi-dollar-string-interpolation

Related Resources

Guard conditions
Guard conditions
Create advanced control flows in when statements
Non-local break & continue
Non-local break & continue
Making inline lambdas truly first-class citizens
UUID in Kotlin Multiplatform
UUID in Kotlin Multiplatform
Work with unique IDs using the Kotlin Standard Library