Re: [RFC] Spread Operator in Array Expression v0.2
| From: | Michał Brzuchalski | Date: | Fri, 05 Apr 2019 09:00:59 +0000 |
| Subject: | Re: [RFC] Spread Operator in Array Expression v0.2 | ||
| References: | 1 2 3 4 5 6 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-105101@lists.php.net to get a copy of this message | ||
pt., 5 kwi 2019 o 10:50 Rowan Collins <rowan.collins@gmail.com> napisał(a):
>
> The original draft discussed this, but there wasn't agreement on how
> identical keys should be handled, e.g.:
>
> $a = ['foo' => 1, ...['foo' => 2]]
>
> Should $['foo'] be 1 or 2? Cases were made for both, and it was pointed out
> that if we get named arguments, the argument spread operator will need to
> work the same way as whatever is decided for arrays.
>
> So the current approach is to get integer keys working first, using the
> same behaviour as for parameters, and then revisit string keys later.
>
So we're talking about providing incomplete feature now, right?
I would opt to the same behaviour as ['foo' => 1] + ['foo' => 2] // where
'foo' key results in 1
But maybe this should be optional voting for that, either way, we're
delivering feature
which has very limited usage which can be confusing, cause I can
array_merge or
use + operator so why can't I use keys with spread operator if I already
have them in
my generator, iterable or array which came from for eg. json_decode or
whatever.
--
regards / pozdrawiam,
--
Michał Brzuchalski
about.me/brzuchal
brzuchalski.com