Expression switch - an alternate proposal
Ali Ebrahimi
ali.ebrahimi1781 at gmail.com
Fri Apr 13 08:07:23 UTC 2018
Hi,
On Fri, Apr 13, 2018 at 12:05 PM, <forax at univ-mlv.fr> wrote:
> I think it's better to first introduce the expression switch with the
> break syntax and then go to the shorthand syntax than do the opposite.
> ...
>
> var topping = switch (food) {
> case BURGER: KETCHUP;
> case SAUSAGE, ASPARAGUS: MUSTARD;
> case ICE_CREAM: FUDGE;
> case BAKED_POTATO:
> Toppings t = new Toppings();
> t.add(BACON);
> t.add(SOUR_CREAM);
> t.add(CHEESE);
> t.add(BACON); // not a typo
> break t;
> default: NOTHING;
> };
>
> (in my current mental world the shorthand syntax use ':' and not '->')
>
I prefer ':= '
var topping = switch (food) {
case BURGER:= KETCHUP;
case SAUSAGE, ASPARAGUS:= MUSTARD;
case ICE_CREAM:= FUDGE;
case BAKED_POTATO:
Toppings t = new Toppings();
t.add(BACON);
t.add(SOUR_CREAM);
t.add(CHEESE);
t.add(BACON); // not a typo
break t;
default:= NOTHING;
};
--
Best Regards,
Ali Ebrahimi
More information about the amber-dev
mailing list