Re: RFC Draft: Comprehensions
| From: | Michał Brzuchalski | Date: | Fri, 05 Apr 2019 08:41:04 +0000 |
| Subject: | Re: RFC Draft: Comprehensions | ||
| References: | 1 2 3 4 5 6 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-105097@lists.php.net to get a copy of this message | ||
Hi Larry,
pt., 5 kwi 2019 o 03:55 Larry Garfield <larry@garfieldtech.com> napisał(a):
>
> Advantages:
>
> * Very compact.
> * Works for both arrays and traversables
> * Would play very nicely with the proposed spread operator for iterables (
> https://wiki.php.net/rfc/spread_operator_for_array).
>
IMO not nicely cause spread operator in current proposal raises an error on
key preserved traversable[1].
This means example like below would fail
$a = ['foo' => true, ...[foreach($_GET as $key => $value) yield $key =>
$value]]; // error
[1] https://wiki.php.net/rfc/spread_operator_for_array#string_keys
--
regards / pozdrawiam,
--
Michał Brzuchalski
about.me/brzuchal
brzuchalski.com