Skip to content

Support JDK 22 multiple patterns in switch case label #612

@NolwennD

Description

@NolwennD

In JEP 456 a little enhancement will come for case label:

var x = 42;
switch (box) {
  case Box(RedBall _), Box(BlueBall _) when x == 42 -> processMatchAllBox(box); // multiple patterns introduce in JDK 22
  case Box(RedBall _) when x == 21, Box(BlueBall _) -> processBox(box);
  case Box(GreenBall _)                -> stopProcessing();
  case Box(_)                          -> pickAnotherBox();
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions