Strings and Interpolation
The string type is represented by String, a sequence of Unicode characters. String literals come in three forms: single-line strings, multi-line strings, and multi-line raw strings.
Single-line strings are enclosed in a pair of single or double quotes. Multi-line strings are enclosed in three single quotes ''' or three double quotes """, and can span multiple lines. Multi-line raw strings start with # and quotes, preserving content as-is without interpreting escape sequences.
Interpolated strings embed the value of expressions into strings using ${expression}. The curly braces can contain any expression, even including declaration statements. Interpolated strings make string concatenation concise and intuitive, avoiding cumbersome + operations. The code on the right demonstrates basic string usage and interpolation functionality.
${...} within them is treated as raw content.Try putting an arithmetic expression or function call inside ${}.