Formatting

To format a string is simple, you just need to prefix your "string" with a $. Like this: $"string". Then you can use curly braces {} to insert as many expressions into your string as you would like.

Let us take a simple example for inserting a variable into a string.

insert_string := "world!"
final := $"Hello {insert_string}"

// Prints "Hello world!"
print(final)

Any expression is allowed when formatting a string, like adding values, calling functions or even if expressions.

final := $"Hello {if true { "world!" }}"

// Prints "Hello world!"
print(final)

Last updated