summaryrefslogtreecommitdiff
path: root/docs
diff options
context:
space:
mode:
authorFilipe Laíns <lains@riseup.net>2023-10-13 07:59:09 +0100
committerJussi Pakkanen <jpakkane@gmail.com>2023-11-22 22:15:13 +0200
commit63453564ee697ebf4741f082b8d678ed15455a51 (patch)
treeffecbc114346ccb2275afe02bafd1518ffc501b1 /docs
parent96f0b3ca38fa3518187429aaec62a6dae9f25500 (diff)
downloadmeson-63453564ee697ebf4741f082b8d678ed15455a51.tar.gz
docs: document out of bounds behavior in str.substring
Signed-off-by: Filipe Laíns <lains@riseup.net>
Diffstat (limited to 'docs')
-rw-r--r--docs/yaml/elementary/str.yml12
1 files changed, 12 insertions, 0 deletions
diff --git a/docs/yaml/elementary/str.yml b/docs/yaml/elementary/str.yml
index 83ab3dd64..9d059cc09 100644
--- a/docs/yaml/elementary/str.yml
+++ b/docs/yaml/elementary/str.yml
@@ -164,6 +164,9 @@ methods:
The method accepts negative values where negative `start` is relative to the end of
string `len(string) - start` as well as negative `end`.
+ If `start` or `end` are out of bounds, the position of the closest character will be used.
+ If `start` is bigger than `end`, the result will be an empty substring.
+
example: |
```meson
# Similar to the Python str[start:end] syntax
@@ -180,6 +183,15 @@ methods:
string.substring(1, -1) # => 'ooba'
```
+ Example with out of bound values:
+
+ ```meson
+ string = 'foobar'
+ string.substring(64) # => ''
+ string.substring(0, 64) # => 'foobar'
+ string.substring(64, 0) # => ''
+ ```
+
optargs:
start:
type: int