Skip to content

switch statements #136

@glelouet

Description

@glelouet

the new switch (with -> ) allows for many changes besides the symbol

  • return a value (can be void as the usual one) double d = switch(o) {…}
  • allows variable declaration with pattern matching case int i -> i+1
  • guarding case float f when f>0 ->…
  • provides yield for block case char c-> {countChar++;yield count;}
  • null case allowed case null -> …
  • deconstruction of records case Segment(Point2D(int x1, int y1), Point2D(int x2, int y2))-> …

https://docs.oracle.com/en/java/javase/25/language/pattern-matching-switch.html

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions