Re: Regarding array_shift()/array_unshift()
| From: | Mike Schinkel | Date: | Fri, 04 Jun 2021 04:15:06 +0000 |
| Subject: | Re: Regarding array_shift()/array_unshift() | ||
| References: | 1 2 3 4 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-114724@lists.php.net to get a copy of this message | ||
> On Jun 3, 2021, at 5:31 AM, Lauri Kenttä <lauri.kentta@gmail.com> wrote:
>
> On 2021-06-03 01:59, Mike Schinkel wrote:
>> 1.) Given Nikita's position that it would only be viable to offer a
>> syntax that simulates method calling for arrays if the methods
>> themselves are immutable can you envision a solution for allowing
>> $array->shift() functionality that would address getting both element
>> and shifted array without resorting to by-reference parameters?
>
> Spread operator support in assignments would solve this nicely:
> [$first, ...$rest] = $array;
Excellent idea!
Anyone else have thoughts on potential use of the spread/variadic operator in array destructuring
assignments?
-Mike