This is true, I remember having done it in the past.

I still think it would be nice and feel natural to have the default
values directly built into the list construct.

It would be a bit faster, because it does not have to allocate a new
temporary array.

Whether this difference matters depends on the case.
In my own philosophy, every code that I write to be reusable, could at
some point be used in a situation where it is repeated a lot, and thus
has a performance impact. So for my taste, it does matter.

This said, I understand it not having the greatest priority.




On Fri, Aug 11, 2017 at 7:46 PM, Andreas Treichel <gmb...@gmail.com> wrote:
> You can merge the result with default values like this:
>
> [$foo, $bar, $foobar] = explode(':', 'foo:bar') + [23, 42, 1337];
> var_dump($foo, $bar, $foobar);
>
>
>
>
> --
> PHP Internals - PHP Runtime Development Mailing List
> To unsubscribe, visit: http://www.php.net/unsub.php
>

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to