-
Notifications
You must be signed in to change notification settings - Fork 205
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
Add swap macro #1724
Comments
Swapping variables will become much easier when a way to destructure (#207) is added. Current method: int a = 1;
int b = 2;
int temp = a;
a = b;
b = temp; With destructuring: int a = 1;
int b = 2;
[a, b] = [b, a]; |
Destructure does not seem like it coming soon, or ever. |
It's a huge part of darts language philosophy to be a concise language to learn. If special syntax would created to solve a bunch of cases like this (that aren't even important enough for the author to argue why they need it in real world programs) the special syntax would make dart more complex and harder to learn. Core language features aren't supposed to be added to solve issues "in the mean time". |
You've got a point. It is just annoying to write 3 lines of code each time you need a tiny swap. That's all. |
swapping two integer variables cannot be made in function, because it alters only the local value.
fact: variable swap takes 3 lines of code.
please add swap macro that do swap instead of doing it in every place we need.
The text was updated successfully, but these errors were encountered: