F-Strings
F-strings let you embed expressions directly inside string literals. Prefix a string with f and use {expression} to interpolate values.
Basic usage
Expressions
Any valid expression can go inside the braces:
Automatic string conversion
Non-string values are automatically converted to their string representation:
var int count = 42
console.println(f"count is {count}") // count is 42
var float pi = 3.14
console.println(f"pi is {pi}") // pi is 3.14
var bool done = true
console.println(f"done: {done}") // done: true
Escaping braces
Use \{ and \} to include literal brace characters:
String concatenation with +
You can also build strings with the + operator. When one side is a string, the other side is automatically converted:
Both f-strings and + concatenation work well for building dynamic strings. F-strings are usually more readable for complex expressions.