RFC proposal - unpack iterator
| From: | Bartłomiej Krukowski | Date: | Wed, 12 Jul 2017 09:22:39 +0000 |
| Subject: | RFC proposal - unpack iterator | ||
| Groups: | php.internals | ||
| Request: | Send a blank email to internals+get-99851@lists.php.net to get a copy of this message | ||
Hello,
From PHP 5.6 we have possibility to add variadic functions and unpacking
arrays via *...*
Would be nice to extend responsibility of *...*. Sometimes in code I can
find lines similar to the following:
$result = array_merge(['some value'], ['some other value'], $array);
I would like to shorten this line to the following:
$result = ['some value', ['some other value'], ...$array];
And even allow to unpack more than one array:
$result = ['some value', ['some other value'], ...$array, ...$secondArray];
Using new operator we can produce shorter and more clearable code. I would
like to create RFC for my proposal. If you think idea can be useful, please
give me an access for creating RFC.
Best regards