Hi Gavin,
 
 
"The scope of a pattern variable is determined by considering the innermost enclosing statement S that contains the pattern variable declaration. The overall scope of a pattern variable V is defined to be (i) those expressions and statements contained in S where V is definitely matched; and (ii) if S is immediately contained by a statement Q, those statements following S contained by Q where V is definitely matched; and (iii) if S is immediately contained by a block, those statements following S contained by that block where V is definitely matched."
 
Have a few clarifications, assuming we take the following example:
 
public void method foo() {
 
 
if (e instanceof String s) {
  // s allowed
} else {
 // s not allowed
}
 // A: s should not be allowed here?
}
 
What is S here? Is it the entire if statement? 
if yes, then by (iii) ,  s should be available at placed marked A if it is definitely matched?
 
Can you  please give an example?
 
Regards,
Manoj.
 
 

Reply via email to