为什么飞船操作员中只有一个等号?
问题描述:
为什么选择宇宙飞船操作员<=>
具有一个等号而不是两个?这是否被视为与一个等号不一致,通常表示赋值,而两个意思比较不一致?
Why was the spaceship operator <=>
chosen to have one equal sign rather than two? Is this seen as inconsistent with one equal sign usually meaning assignment, and two meaning comparison?
答
为什么会有两个? <=
,>=
和!=
中只有一个.一点也不矛盾.只有==
是不一致的,这是为了避免与赋值运算符发生冲突.
Why would it have two? There's only one in <=
, >=
and !=
. It's not inconsistent at all. Only ==
is inconsistent, and that's to avoid conflicts with the assignment operator.