1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

docs: add an example of zero padding in string interpolation

This commit is contained in:
Delyan Angelov 2021-01-23 09:02:28 +02:00
parent c2d501e8a9
commit 362a83d0c6
No known key found for this signature in database
GPG Key ID: 66886C0F12D595ED

View File

@ -480,8 +480,9 @@ The compiler takes care of the storage size, so there is no `hd` or `llu`.
```v ```v
x := 123.4567 x := 123.4567
println('x = ${x:4.2f}') println('x = ${x:4.2f}')
println('[${x:10}]') // pad with spaces on the left println('[${x:10}]') // pad with spaces on the left => [ 123.457]
println('[${int(x):-10}]') // pad with spaces on the right println('[${int(x):-10}]') // pad with spaces on the right => [123 ]
println('[${int(x):010}]') // pad with zeros on the left => [0000000123]
``` ```
### String operators ### String operators