You can place any expression after the $. For a single variable expression, you can simply place the variable name after the $ and Scala will interpret all the characters until the last character of the variable identifier.
In our example above, the variable identifier was country. Scala interpreted the variable until the y of country and afterward, processed ! like any other character.
Let’s now try to embed a mathematical expression in a string. As a mathematical expression doesn’t have any identifiers, letting the compiler know what to interpret and what to take as a regular character is done by modifying the syntax for single variable expressions.
Syntax for Expressions with Non-Identifier Characters
The expression you want the Scala compiler to process will be placed in curly brackets. The opening curly bracket will immediately follow the $.