> De: "Brian Goetz" <[email protected]> > À: "Kevin Bourrillion" <[email protected]> > Cc: "Remi Forax" <[email protected]>, "amber-spec-experts" > <[email protected]> > Envoyé: Lundi 18 Décembre 2017 22:25:15 > Objet: Re: New JEP: Switch Expressions for the Java Language
> On 12/18/2017 4:16 PM, Kevin Bourrillion wrote: >> On Mon, Dec 11, 2017 at 11:28 AM, Brian Goetz < [ >> mailto:[email protected] >> | [email protected] ] > wrote: >>>> I think most of my questions surround how these changes will (or should ) >>>> affect >>>> non-expression switches. >>>> * Should we retcon `case A, B:` onto regular switches, with the same >>>> semantics? >>> Absolutely; I thought this was already present in the JEP, but if not, I'll >>> clarify. >>>> * Should we retcon `case null:` onto regular switches, with the same >>>> semantics? >>> Absolutely; same comment. >> There is a problem here, especially among users who learn Java in the future >> and >> never know how `switch` used to work. >> They will know that `null` is a valid thing to switch on, and when they don't >> see `case null` they will assume that the `default` clause is being executed. >> That's unfortunate. > Why would they assume that? What they'll learn in future Java school is "If > there's no explicit case null, switch throws NPE". Which is exactly as it is > today -- except that you can't spell "case null". In no case will a switch > without a "case null" execute the default clause on null input. yes, this is how i will teach it :) Rémi
