-
Notifications
You must be signed in to change notification settings - Fork 1.7k
return variable of a function #1621
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
Comments
This comment was originally written by [email protected] Sorry, I don't know how to change the type of issue to "Enhancement". |
This comment was originally written by [email protected] I thought of this because many of my JavaScript functions end up declaring a variable that I will in the end return, which is kind of redundant. The return variable name should be short in length, although my example has quite a long one. It also should be fixed, instead of changing with the function name as in BASIC, since the function name should be separate from the function body, so that renaming (on the programmer's side) is easy. |
Removed Type-Defect label. |
Added Triaged label. |
I think it is very common for people to use "result" for this, and for them to type: var result; return result; This seems short and simple enough that it might not |
This comment was originally written by [email protected] But internally, will it be two variables or somehow optimized into one? |
Added WontFix label. |
This is a minor change with just bug fixes: * Handle trailing commas in for-loop updaters (#1354). * Format `||` patterns like fallthrough cases in switch expressions (#1602). * Handle comments and metadata before variables more gracefully (#1604). * Ensure comment formatting is idempotent (#1606). * Better indentation of leading comments on property accesses in binary operator operands (#1611). * Don't crash on doc comments in local variable declarations (#1621). This won't affect much code, but it does change the formatting in some cases. Change-Id: I2d52fee92aecbc24315e4f1a89360af85ec85942 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/401482 Auto-Submit: Bob Nystrom <[email protected]> Commit-Queue: Alexander Thomas <[email protected]> Reviewed-by: Alexander Thomas <[email protected]>
This issue was originally filed by [email protected]
The return variable of the function should be able to be referenced in the function body, like in Visual Basic. It will start off with a value of null, and be possibly changed by the function to return a value, e.g. something like "returnset <expression>;", that is like the return statement, but does not pass back control to calling process. Even better, give the variable a fixed identifier like "_returnvalue" so that expressions or array functions can change the value, e.g. "_returnvalue++;".
The text was updated successfully, but these errors were encountered: