Skip to content

interpreter: Add a flatten() method to arrays #14586

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

dcbaker
Copy link
Member

@dcbaker dcbaker commented May 9, 2025

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.

x = [meson.get_external_property('may_be_array)].flatten()
x = ['a', ['b', 'c']]
assert(x.flatten() == ['a', 'b', 'c'])

@dcbaker dcbaker added this to the 1.9 milestone May 9, 2025
@dcbaker dcbaker requested a review from jpakkane as a code owner May 9, 2025 18:26
Copy link

@keith-packard keith-packard left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice fix that keeps usage simple.

@dcbaker dcbaker force-pushed the submit/array-flatten branch from d0df917 to 4f2d971 Compare May 9, 2025 19:50
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'])
```
@dcbaker dcbaker force-pushed the submit/array-flatten branch from 4f2d971 to d06201d Compare May 10, 2025 15:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants