News for hackers. Stuff that matters.
Re:Upcoming changes in PHP 7.1 by ars on Monday May 23, 2016 @12:12PM (#11754771)
> has been shortened to [] and now lets you specify keys (disclaimer: I was involved in both of these

Maybe you can answer this for me.

Will this work:

  $f = [$c, $d] = [1, 2];
i.e. set $c and $d to 1 and 2, then return the array and store in $f.
Re:Upcoming changes in PHP 7.1 by meritt on Monday May 23, 2016 @12:24PM (#11754846)
It should because:

    $f = list($c, $d) = [1, 2];
does exactly as you describe and this is literally just a shorthand syntax for accessing list().
Re:Upcoming changes in PHP 7.1 by ars on Monday May 23, 2016 @12:36PM (#11754927)
Thanks. What about:

  $c = 2;
  $d = 3;

  $f = [$c, $d] = [1, 2];
Is $f: 2, 3 or 1, 2? I assume 1, 2 because if not then it's both an array constructor and destructurer at the same time which would be interesting.

Plus:

  $f = $c = $d;
is 3;
Re:Upcoming changes in PHP 7.1 by claar on Monday May 23, 2016 @01:34PM (#11755394)
Let's break this up a bit, remembering that assignment is right-associative:

  $c = 2; # Assign 2 to $c
  $d = 3; # Assign 3 to $d

  [$c, $d] = [1, 2]; # Assign 1 to $c, assign 2 to $d

  $f = [$c, $d]; # Assign [1, 2] to $f