by GavinBierman · 4y ago · 0 comments
Object foo = ...
if (foo instanceof String s) {
System.out.println(s.toLowerCase())
}
In this case, the scope of the pattern variable `s` is just the then block, so are free to reuse it elsewhere in the block.No comments yet.