Re: [RFC][DISCUSSION] Allow default value in list() syntax
| From: | Dan Ackroyd | Date: | Mon, 09 Nov 2015 15:24:00 +0000 |
| Subject: | Re: [RFC][DISCUSSION] Allow default value in list() syntax | ||
| References: | 1 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-89121@lists.php.net to get a copy of this message | ||
Hi Reeze,
On 9 November 2015 at 13:35, reeze <reeze@php.net> wrote:
> Hi internals!
>
> I'd like to open a discussion on the RFC to allow set default values for
> list() assignment:
> https://wiki.php.net/rfc/list_default_value.
>
> What is your idea?
I find the list construct to be quite magic already. Isn't it possible
to get the affect that you want without adding anything to the core by
doing this:
$defaults = ['default', 'default'];
$input = [1];
list($a, $b) = array_replace($defaults, $input);
I'd find that way easier to understand and explain to junior devs,
compared to having more functionality added to the 'list' magicness.
cheers
Dan