-
Notifications
You must be signed in to change notification settings - Fork 1k
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
Variable Aliasing "Out var" style #899
Comments
You can use if (Company.CEO.Age is var CEOAge && CEOAge >= 21 && CEOAge < 45) {
} |
@HaloFour beat me by seconds :D |
@HaloFour as far as I know, |
Or, using my suggestion of an "as pattern": if (Company.CEO.Age as var CEOAge >= 21 && CEOAge < 45) {
} (which is basically the same as this suggestion and neatly avoids the need to introduce the variable and perform the comparison as two separate expressions). |
@svick if I build a solution in VS with debug variant, it will still use the release version of the compiler, right? |
@Logerfo How you compile the compiler doesn't matter. What matters is what you tell the compiler to do. If you tell it to compile your code in Debug mode, it produces less optimized (and easier debuggable) IL, which in this case includes the unnecessary flag check. And the Debug/Release option in SharpLab has the same effect as the Debug/Release option in VS. |
@svick thank you very much |
Hi C# Team,
I love how you can create, assign, and use variables with out var in situations like this:
I would like to propose that the language be extended to allow similar constructs where ever variables are used. Specifically comparison evaluations.
Here are some examples of what I would like to be able to do:
I think that scoping rules should be identical to Out-Var.
This has the following benefits:
The text was updated successfully, but these errors were encountered: