> On Oct 16, 2019, at 5:21 PM, Bob Weinand <bobw...@hotmail.com> wrote:
> what's the concrete advantage of this syntax as opposed to the already 
> possible:
> 
> $value = [
>  A1 => A2,
>  B1 => B2,
> ][expr()] ?? C;

Speaking specifically to your example, it does not handle multiple cases. IOW, 
you cannot do this:

$value = [
   A1 => A2,
   B1,C1, D1 => BCD2,
   E1 => E2,
][expr()] ?? F;

A lesser concern is it must allocate memory for the array simply to implement 
the switch. Given that I would almost always avoid using that approach because 
I assume it is always best not to allocate memory unless really needed.  Even 
if allocating the memory is not a problem, I expect other developers might have 
aversion to that technique based on similar assumptions.

-Mike
P.S. I am not sold on the proposal as is; I plan a follow up later with my 
concerns.

Reply via email to