-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
Giving different variable names when destructuring structs #52191
Comments
It's not at all obvious to me whether the name of the field should go on the left or right side of the |
That's a really good point. I was thiking as we assign But the fact that there is this ambiguity definitely would make it complicated.
I was not trying to reproduce the exact Rust syntax, just wanted to show that they were doing something similar. |
This is also discussed in #51940. As another example, JavaScript has syntax for both setting a default value and assigning the name (field names are on the left, variables on the right): const { a: a1 = aDefault, b = bDefault } = obj; |
Yes, as I commented in the other issue mentioned by @Pangoraw, I would prefer to use Analogous to JavaScript, if we want to have renaming we could use Julia's own (; a as a1 = aDefault, b = bDefault, c as c1) = obj |
Right now it's possible (and great) to do
However, in some cases (we want to destructure multiple
Foo
in the same scope) it would be great to be able to directly use different variable names and do something likeThere is a similar pattern in Rust described here
The text was updated successfully, but these errors were encountered: