Skip to content

Commit c804ba6

Browse files
authored
Merge pull request #292 from d4v1d03/main
added usage of r prefix and string interpolation
2 parents 4047eb7 + d7109f8 commit c804ba6

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

docs/user_docs/support/faq-kcl.md

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2492,4 +2492,21 @@ config = {
24922492
age = 25
24932493
}
24942494
alice: Person = config
2495-
```
2495+
```
2496+
2497+
## 58. Please explain the relationship and usage of 'r' prefix in a String and String Interpolation.
2498+
2499+
In KCL, we can use `${..}` for string interpolation. But in some cases, we don't want to escape it. Therefore, we use create a raw string by prefixing the string literal with `'r'` or `'R'`. An example KCL code over here is:
2500+
2501+
```KCL
2502+
worldString = "world"
2503+
s = "Hello ${worldString}"
2504+
raw_s = r"Hello ${worldString}"
2505+
```
2506+
2507+
The output comes out as:
2508+
2509+
```bash
2510+
worldString: world
2511+
s: Hello world
2512+
raw_s: Hello ${worldString}

0 commit comments

Comments
 (0)