Re: Array spread append
| From: | mickmackusa | Date: | Thu, 06 Apr 2023 08:00:38 +0000 |
| Subject: | Re: Array spread append | ||
| References: | 1 2 3 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-119821@lists.php.net to get a copy of this message | ||
Call me sentimental, but are we just trying to choke out the few remaining
reasons to keep array_push() in the language?
Okay, yeah, sometimes at is a drag that the first parameter has to be
declared in advance and is modified by reference (which means you can't
enjoy null coalescing or short ternary syntax directly in the first
parameter) but...
The whole purpose of array_push() is to append one or more elements to an
array. Spreading the second parameter makes this task simple/clean.
https://3v4l.org/RcKRD
I feel like PHP already has an extensive toolbelt for merging array data.
I am not yet sold on this new/strange implementation of the spread operator.
Mick Harner
mickmackusa