[patterns] Null handling
Remi Forax
forax at univ-mlv.fr
Sat Oct 14 10:21:16 UTC 2017
Apart if i've missed something, the implementation is not complete,
null handling is explicit, i.e.
static void testSwitchNumber(Number i) {
switch(i) {
case 1: System.out.println("One");break;
case null:
default: System.out.println("Other");break;
}
}
cheers,
Rémi
----- Mail original -----
> De: "Tagir Valeev" <amaembo at gmail.com>
> À: "amber-dev" <amber-dev at openjdk.java.net>
> Envoyé: Samedi 14 Octobre 2017 11:34:14
> Objet: [patterns] Null handling
> Hello!
>
> Sorry if I'm missing something. Is this behavior difference intended
> or just implementation is not complete yet?
>
> static void testSwitchInteger(Integer i) {
> switch(i) {
> case 1: System.out.println("One");break;
> default: System.out.println("Other");break;
> }
> }
>
> static void testSwitchNumber(Number i) {
> switch(i) {
> case 1: System.out.println("One");break;
> default: System.out.println("Other");break;
> }
> }
>
> testSwitchNumber(null); // prints "Other"
> testSwitchInteger(null); // NPE
>
> WIth best regards,
> Tagir Valeev.
More information about the amber-dev
mailing list