yield can not be followed by an underscore ?

Remi Forax forax at univ-mlv.fr
Tue Jun 25 07:04:49 UTC 2024


Hello,
javac is not able to parse "yield _ -> ...".

Here is a reproducer.

public class SwitchYieldAndUnderscore {
  public static void main(String[] args) {
    Consumer<String> value = switch (args[0]) {
      case "foo" -> {
        yield _ -> {};
      }
      default -> throw new AssertionError();
    };
  }
}

regards,
Rémi


More information about the amber-dev mailing list