Delphi: XOR vs <> pour booléens
-
26-10-2019 - |
Question
Y at-il une différence entre:
procedure InequalityMsg(ABool1, ABool2 : Boolean);
begin
if ABool1 <> ABool2 then
ShowMessage('Yeah, they''re not the same');
end;
et
procedure InequalityMsg(ABool1, ABool2 : Boolean);
begin
if ABool1 XOR ABool2 then
ShowMessage('Yeah, they''re not the same');
end;
La solution
Non, ils sont exactement les mêmes. (Eh bien, le code généré peut être différente, mais le comportement ne sera jamais montrer aucune différence. Et, que la performance va, cette question est très peu importante.)
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow