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

Switch using "->" handled incorrectly as switch expression #280

Open
pcimcioch opened this issue Dec 29, 2022 · 0 comments
Open

Switch using "->" handled incorrectly as switch expression #280

pcimcioch opened this issue Dec 29, 2022 · 0 comments

Comments

@pcimcioch
Copy link

I can write the following method in Java:

enum Direction {LEFT, RIGHT}

void displayDirection(Direction direction) {
  switch(direction) {
    case LEFT -> System.out.println("Turn Left");
    case RIGHT -> System.out.println("Turn Right");
  }
}

This is the correct java code. When I create method with this body though, it gets replaced with something like:

void displayDirection(Direction direction) {
  switch(direction) {
    case LEFT: 
      System.out.println("Turn Left");
      yield;
    case RIGHT:
      System.out.println("Turn Right");
      yield;
  };
}

It seems as if I use "->" in standard switch, library automatically treats it as switch expression

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant