On 5 November 2014 11:43, Chris Wright <c...@daverandom.com> wrote:

> On 5 November 2014 11:22, Leigh <lei...@gmail.com> wrote:
>
>> On 4 November 2014 18:14, Rowan Collins <rowan.coll...@gmail.com> wrote:
>> >
>> > If anything, I think I would expect the keys of splatted arrays to be
>> discarded, since it seems most natural to use this in a list context, but I
>> can imagine always having to check in the manual.
>>
>> I agree on this point. Duplicate keys should not overwrite each other.
>>
>> [...$foo, ...$bar] should literally unpack the values as if they were
>> comma delimited and discard all key information.
>>
>>
> Here's how I picture this, which is the rationale for my view on how it
> should behave:
>
> $foo = ['a' => 1, 'b' => 2, 'c' => 3];
> $bar = ['c' => 4, 'd' => 5, 'e' => 6, ...$foo];
> // is identical to writing
> $bar = ['a' => 1, 'b' => 2, 'c' => 3, 'c' => 4, 'd' => 5, 'e' => 6];
>
> http://3v4l.org/inqtg#v540
>
> In other words, in that scenario it's basically syntactic sugar to avoid
> having to write out the "body" of the array twice, and would behave
> identically as if you had done this.
>
> Of course, if the majority opinion that this is not the correct approach,
> I'm happy to admit I'm wrong :-)
>


Having performed an extremely unscientific (but I think reasonably fair and
unbiased) straw-poll of a few people today, I can tell you that the general
expectation of everyone I have spoken to about it is that it would work the
same as outlined above.

Reply via email to