We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
It would be nice if we had syntax to destructure arrays, objects and other types.
Syntax could look something like this:
let my_array = [0, 1, 2]; let [a, b, c] = my_array; print(a); // 0 print(b); // 1 print(c); // 2
This is similar to JavaScript and this also lets you emulate tuples! Like:
let my_tuple = ["Hello", "World!"]; let [hello, world] = my_tuple; print(hello); // Hello print(world); // World!
The text was updated successfully, but these errors were encountered:
This might be doable as Rhai only contains two literal syntax that can be matched against: arrays and maps. I'll look into that.
But then, once we match on arrays, we probably need the spread operator ... to do whacky things like match both ends, match the middle etc.
...
So it must consider all possible combinations: [a, b, c], [a, b, ...], [..., b, c], [a, ... c], [..., b, ...]...
[a, b, c]
[a, b, ...]
[..., b, c]
[a, ... c]
[..., b, ...]
And if you add _ to match one slot, then there will be many more patterns to handle.
_
Sorry, something went wrong.
No branches or pull requests
It would be nice if we had syntax to destructure arrays, objects and other types.
Syntax could look something like this:
This is similar to JavaScript and this also lets you emulate tuples! Like:
The text was updated successfully, but these errors were encountered: