実用的なパターンマッチングが標準に! ● JEP 440 Record Patterns ● JEP 441 Pattern Matching for switch sealed interface Op permits Output, Goto {} // 命令 record Output(String message) implements Op {} record Goto(int no) implements Op {} List codes = List.of( // プログラム new Output("hello"), new Output("world"), new Goto(0)); int counter = 0; void clock() { // 命令実行 counter++; switch(codes.get(counter-1)) { // 命令ごとの分岐 case Output(var msg) -> System.out.println(msg); case Goto(var no) -> counter = no; } }