Re: [RFC] Combined Comparison (Spaceship) Operator
Hi Yasuo,
> On 23 Jan 2015, at 00:16, Yasuo Ohgaki <[email protected]> wrote:
>
> Hi all,
>
> On Fri, Jan 23, 2015 at 7:48 AM, Larry Garfield <[email protected]>
> wrote:
>
>> The examples say nothing about mixing types, though. Eg, what would these
>> return:
>>
>> return 0 <=> "0"
>>
>> return "" <=> 0
>>
>> return 1 <=> [1, 2, 3]
>>
>> Ignoring object property names and going by the order of the property
>> definition seems like asking for trouble, too.
>>
>
> It should be the same as '===', IMO.
> Only the same type should return 0.
> Object has the same id should return 0.
> Arrays would be matter of discussion.
Having it be the same as === would be inconsistent with our existing sorting and comparison
behaviour, so I don’t think it should be changed. If we made it strict like that, we’d also have
to define a strict < and > as well, otherwise we have a problem, because in some cases ($x !==
$y && !($x < $y) && !($x > $y)) is TRUE.
Thanks.
--
Andrea Faulds
http://ajf.me/
Thread (30 messages)