-
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
Allow ref assignment in ternary operator and switch expression #2507
Comments
Works fine for me as: bool isRight = false;
string left = null, right = null;
ref var side = ref isRight ? ref right : ref left;
side = "whatever"; A couple of notes:
You still have to write it as: The same holds here. So you need: A bit of a mouthful, but totally supported. |
Can you file a separate issue for that? Compounding multiple requests into one issue just makes it harder to handle them. |
Oh I see, that was unexpected that we need This syntax is not so intuitive but still fine. I think the Thank you very much |
You're welcome :) The intuition here is that you can only assign a ref with
I would personally agree. :) It might not happen in the initial release due to time constraints. but i def think it could happen later down the line. |
Currently now this code above throw error
A ref or out value must be an assignable variable [Assembly-CSharp]
I think it should be available. Is it possible? It should also work with
switch expression
tooThe text was updated successfully, but these errors were encountered: