parent
b51bce070e
commit
5f46ea116c
4 changed files with 49 additions and 5 deletions
@ -0,0 +1,20 @@ |
||||
## Added 'fill' kwarg to int.to_string() |
||||
|
||||
int.to_string() now accepts a `fill` argument. This allows you to pad the |
||||
string representation of the integer with leading zeroes: |
||||
|
||||
```meson |
||||
n = 4 |
||||
message(n.to_string()) |
||||
message(n.to_string(length: 3)) |
||||
|
||||
n = -4 |
||||
message(n.to_string(length: 3)) |
||||
``` |
||||
|
||||
OUTPUT: |
||||
```meson |
||||
4 |
||||
004 |
||||
-04 |
||||
``` |
@ -0,0 +1,9 @@ |
||||
project('test_fill_in_int_to_string') |
||||
|
||||
n = 4 |
||||
assert(n.to_string() == '4') |
||||
assert(n.to_string(fill: 3) == '004') |
||||
assert(n.to_string(fill: -3) == '4') |
||||
|
||||
n = -4 |
||||
assert(n.to_string(fill: 3) == '-04') |
Loading…
Reference in new issue