diff options
author | Nomura <nomura.rh@gmail.com> | 2023-09-07 20:26:20 +0200 |
---|---|---|
committer | Xavier Claessens <xclaesse@gmail.com> | 2023-09-09 19:03:22 -0400 |
commit | 5f46ea116c6f80edd3633c03aacd7427ef3d0cec (patch) | |
tree | 8a962727656fe58689e38b07296199bbd77d9b0a /docs | |
parent | b51bce070eead2b65e56f087acf23829a6304ae2 (diff) | |
download | meson-5f46ea116c6f80edd3633c03aacd7427ef3d0cec.zip meson-5f46ea116c6f80edd3633c03aacd7427ef3d0cec.tar.gz meson-5f46ea116c6f80edd3633c03aacd7427ef3d0cec.tar.bz2 |
Add support for padding zeroes in int.to_string() method
Diffstat (limited to 'docs')
-rw-r--r-- | docs/markdown/snippets/int_to_string_fill.md | 20 | ||||
-rw-r--r-- | docs/yaml/elementary/int.yml | 12 |
2 files changed, 32 insertions, 0 deletions
diff --git a/docs/markdown/snippets/int_to_string_fill.md b/docs/markdown/snippets/int_to_string_fill.md new file mode 100644 index 0000000..2b0d250 --- /dev/null +++ b/docs/markdown/snippets/int_to_string_fill.md @@ -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 +```
\ No newline at end of file diff --git a/docs/yaml/elementary/int.yml b/docs/yaml/elementary/int.yml index 65ab959..f8d8e25 100644 --- a/docs/yaml/elementary/int.yml +++ b/docs/yaml/elementary/int.yml @@ -14,3 +14,15 @@ methods: - name: to_string returns: str description: Returns the value of the number as a string. + + optargs: + fill: + type: int + description: | + Left fill the string with zeros until it reaches the length + specified by this argument. A leading negative sign counts towards + the length, and is handled by inserting the padding after the `-` + character rather than before. The original string is returned if the + value provided is less than or equal to the former's length. + + |