aboutsummaryrefslogtreecommitdiff
path: root/docs/markdown/snippets/array-flatten.md
diff options
context:
space:
mode:
authorDylan Baker <dylan@pnwbakers.com>2025-05-09 11:21:53 -0700
committerDylan Baker <dylan@pnwbakers.com>2025-07-19 18:36:40 -0700
commit6e379f0090b606786d540001b4a2de52f57e5e47 (patch)
treece0d303801a5a82b885f4690bbb6004b25258b96 /docs/markdown/snippets/array-flatten.md
parentc3531971abca0d0987e919f452227b61b392f969 (diff)
downloadmeson-6e379f0090b606786d540001b4a2de52f57e5e47.zip
meson-6e379f0090b606786d540001b4a2de52f57e5e47.tar.gz
meson-6e379f0090b606786d540001b4a2de52f57e5e47.tar.bz2
interpreter: Add a flatten() method to arrays
This allows users to do two things, flatten potentially nested arrays themselves, and, to safely convert types that may be an array to not an array. ```meson x = [meson.get_external_property('may_be_array)].flatten() ``` ```meson x = ['a', ['b', 'c']] assert(x.flatten() == ['a', 'b', 'c']) ```
Diffstat (limited to 'docs/markdown/snippets/array-flatten.md')
-rw-r--r--docs/markdown/snippets/array-flatten.md5
1 files changed, 5 insertions, 0 deletions
diff --git a/docs/markdown/snippets/array-flatten.md b/docs/markdown/snippets/array-flatten.md
new file mode 100644
index 0000000..eaab19c
--- /dev/null
+++ b/docs/markdown/snippets/array-flatten.md
@@ -0,0 +1,5 @@
+## Array `.flatten()` method
+
+Arrays now have a `.flatten()` method, which turns nested arrays into a single
+flat array. This provides the same effect that Meson often does to arrays
+internally, such as when passed to most function arguments.