mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
doc: minor update for $\{\} (#16440)
This commit is contained in:
parent
017ace6ea7
commit
5dc5766def
@ -600,15 +600,15 @@ For more advanced `string` processing and conversions, refer to the
|
|||||||
|
|
||||||
#### String interpolation
|
#### String interpolation
|
||||||
|
|
||||||
Basic interpolation syntax is pretty simple - use `$` before a variable name. The variable will be
|
Basic interpolation syntax is pretty simple - use `${` before a variable name and `}` after. The
|
||||||
converted to a string and embedded into the literal:
|
variable will be converted to a string and embedded into the literal:
|
||||||
|
|
||||||
```v
|
```v
|
||||||
name := 'Bob'
|
name := 'Bob'
|
||||||
println('Hello, ${name}!') // Hello, Bob!
|
println('Hello, ${name}!') // Hello, Bob!
|
||||||
```
|
```
|
||||||
|
|
||||||
It also works with fields: `'age = $user.age'`. If you need more complex expressions, use `${}`:
|
It also works with fields: `'age = ${user.age}'`. You may also use more complex expressions:
|
||||||
`'can register = ${user.age > 13}'`.
|
`'can register = ${user.age > 13}'`.
|
||||||
|
|
||||||
Format specifiers similar to those in C's `printf()` are also supported. `f`, `g`, `x`, `o`, `b`,
|
Format specifiers similar to those in C's `printf()` are also supported. `f`, `g`, `x`, `o`, `b`,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user