Skip to content

Commit 8d8e9ab

Browse files
Note that format!() only supports bare identifiers in the string
There is place to expand more on the possibilities with it (e.g `{0}` or `{name}, name = `, but it can be seen in the documentation.
1 parent 39b5e93 commit 8d8e9ab

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

src/language/strings.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,9 @@ let age = 42;
116116
let str = format!("Person {{ name: {name}, age: {age} }}");
117117
```
118118

119+
Note that `format!` only supports embedding variable names in the string; more complex
120+
expressions are spelled like `format!("1 + 1 = {}", 1 + 1)`.
121+
119122
Custom classes and structs can also be interpolated in C# due to the fact that
120123
the `ToString()` method is available for each type as it inherits from `object`.
121124

0 commit comments

Comments
 (0)