Skip to content
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

Clarify switch expression usage #4865

Closed
MaryaBelanger opened this issue May 11, 2023 · 0 comments · Fixed by #4887
Closed

Clarify switch expression usage #4865

MaryaBelanger opened this issue May 11, 2023 · 0 comments · Fixed by #4887
Assignees
Labels
a.language Relates to the Dart language tour e1-hours Can complete in < 8 hours of normal, not dedicated, work from.team Reported by Dash docs team member p2-medium Necessary but not urgent concern. Resolve when possible. st.triage.ltw Indicates Lead Tech Writer has triaged

Comments

@MaryaBelanger
Copy link
Contributor

MaryaBelanger commented May 11, 2023

dart-lang/language#3061

https://dart.dev/language/branches#switch-expressions

Change example to:

enum Color { red, blue, green }

void main() {
  final color = Color.red;
  (switch (color) {
    Color.red => "red",
    Color.blue => "blue",
    Color.green => "green",
  });
}

The solution is to clarify that they can't be used as the beginning of an expression. Then, if they really need to do that, parenthesize it like the above example. But I think instead of parenthesizing it, these cases should really just be using a switch statement. I'm hesitant to mention the parenthesized syntax since it's a work around to achieve behavior that's already built into switch statements.

@MaryaBelanger MaryaBelanger self-assigned this May 11, 2023
@danagbemava-nc danagbemava-nc added st.triage.triage-team Triage team reviewing and categorizing the issue a.language Relates to the Dart language tour p2-medium Necessary but not urgent concern. Resolve when possible. e1-hours Can complete in < 8 hours of normal, not dedicated, work and removed st.triage.triage-team Triage team reviewing and categorizing the issue labels May 12, 2023
@atsansone atsansone added the st.triage.ltw Indicates Lead Tech Writer has triaged label May 12, 2023
MaryaBelanger added a commit that referenced this issue May 16, 2023
Fixes #4865 

---------

Co-authored-by: Anthony Sansone <[email protected]>
Co-authored-by: Parker Lougheed <[email protected]>
@atsansone atsansone added the from.team Reported by Dash docs team member label Aug 8, 2023
rmacnak-google pushed a commit to rmacnak-google/site-www that referenced this issue Sep 5, 2023
Fixes dart-lang#4865 

---------

Co-authored-by: Anthony Sansone <[email protected]>
Co-authored-by: Parker Lougheed <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
a.language Relates to the Dart language tour e1-hours Can complete in < 8 hours of normal, not dedicated, work from.team Reported by Dash docs team member p2-medium Necessary but not urgent concern. Resolve when possible. st.triage.ltw Indicates Lead Tech Writer has triaged
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants