The latter will cause you to think that you'll be automatically warned
if you accidentally type = instead of ==, which means that you'll have a
much harder time finding the bug when you inevitably write if (y=x).

Richard Bos said:
> "Ajay" <> wrote:
>
>> What is the difference betweem
>>
>> if (x == 1)
>>
>> AND
>>
>> if (1==x)
>
> The latter will cause you to think that you'll be automatically warned
> if you accidentally type = instead of ==,

Wrong. It will cause you to *know* that you'll be automatically warned if
you accidentally type = instead of == when comparing a constant and an
lvalue.
> which means that you'll have a
> much harder time finding the bug when you inevitably write if (y=x).

No. I agree that such a bug is *hard* to find if your compiler doesn't
notice it, but just because a related error is *easier* to find, that does
not make /this/ error *harder* to find than it was before.

Share This Page

Welcome to The Coding Forums!

Welcome to the Coding Forums, the place to chat about anything related to programming and coding languages.

Please join our friendly community by clicking the button below - it only takes a few seconds and is totally free. You'll be able to ask questions about coding or chat with the community and help others.
Sign up now!