Re: Suggestion: Inconsistency: Allow array spread operator to work on string keys

From: Date: Wed, 02 Dec 2020 18:15:44 +0000
Subject: Re: Suggestion: Inconsistency: Allow array spread operator to work on string keys
References: 1 2  Groups: php.internals 
Request: Send a blank email to internals+get-112380@lists.php.net to get a copy of this message
On Wed, Dec 2, 2020 at 10:46 AM G. P. B. <george.banyard@gmail.com> wrote: > The reason why this has been deferred is because of which semantics should > be used for duplicate string keys. > > Do we use the addition between two arrays semantics or the array_merge() > semantics? See: https://3v4l.org/7QbWv array_merge is the only one that makes sense. Addition of positional arrays is nonsensical: [1,2,3] + [4,5,6] ===> [1,2,3] As for named keys, every other language with a similar construct (perl, python, javascript) uses array_merge semantics. Truth is I'm sorely disappointed that + works like it does, but there's no fixing it now. --c

« previous php.internals (#112380) next »