Den 2017-08-12 kl. 02:37, skrev Andreas Hennings:
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
One could argue that:
[$foo, $bar, $foobar = 1337] = explode(':', 'foo:bar');
is more readable. I find it a small but nice addition
that doesn't clutter the language.
r//Björn
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php