summaryrefslogtreecommitdiff
path: root/docs
diff options
context:
space:
mode:
authorJouke Witteveen <j.witteveen@gmail.com>2025-07-24 14:17:55 +0200
committerJussi Pakkanen <jussi.pakkanen@mailbox.org>2025-11-28 12:41:01 +0200
commit0fb9c5a6839205cc32c2632dd20f723f00dc165b (patch)
tree0dab116976dbf400ed9f95860ac683435466d321 /docs
parent5e399434f2c3bb791f0c16f01fa85680c3f90fb7 (diff)
downloadmeson-0fb9c5a6839205cc32c2632dd20f723f00dc165b.tar.gz
interpreter: Add a slice() method to arrays
This can come in handy for instance when a custom target creates both headers and sources. Slicing the output of a `to_list()` call provides convenient access to just the headers or just the sources.
Diffstat (limited to 'docs')
-rw-r--r--docs/markdown/snippets/array-slice.md3
-rw-r--r--docs/yaml/elementary/array.yml27
2 files changed, 30 insertions, 0 deletions
diff --git a/docs/markdown/snippets/array-slice.md b/docs/markdown/snippets/array-slice.md
new file mode 100644
index 000000000..8b503bce9
--- /dev/null
+++ b/docs/markdown/snippets/array-slice.md
@@ -0,0 +1,3 @@
+## Array `.slice()` method
+
+Arrays now have a `.slice()` method which allows for subsetting of arrays.
diff --git a/docs/yaml/elementary/array.yml b/docs/yaml/elementary/array.yml
index 7d0480a04..7183d1aff 100644
--- a/docs/yaml/elementary/array.yml
+++ b/docs/yaml/elementary/array.yml
@@ -37,6 +37,33 @@ methods:
type: any
description: Fallback value that is returned if the index is out of range.
+- name: slice
+ returns: array[any]
+ since: 1.10.0
+ description: |
+ Return a selection of the elements of the array starting at index `start`
+ and continuing with `step` size jumps until `stop`. Negative indices count
+ from the back of the array. The step size cannot be zero, but may be
+ negative. If it is negative, `start` and `stop` default to the end and
+ beginning of the array, respectively. If `step` is positive, `start`
+ defaults to 0 and `stop` defaults to the length of the array. Either both
+ or none of `start` and `stop` must be provided to prevent ambiguity.
+
+ optargs:
+ start:
+ type: int
+ description: The lower bound of the slice
+
+ stop:
+ type: int
+ description: The upper bound of the slice
+
+ kwargs:
+ step:
+ type: int
+ default: 1
+ description: The step size
+
- name: length
returns: int
description: Returns the current size of the array.