What is the difference between 0 = value1

Questions about MultiCharts and user contributed studies.
User avatar
TJ
Posts: 6550
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 965 times
Been thanked: 1892 times

What is the difference between 0 = value1

Postby TJ » 26 Sep 2008

What is the difference between

if 0 = value1 then...

and

if value1 = 0 then...



I see some people do it the first method. I wonder if there is any advantages?

Huoliuhi
Posts: 1
Joined: 16 Sep 2008
Contact:

nothing

Postby Huoliuhi » 29 Sep 2008

I'm going to bump the tread up.

User avatar
Marina Pashkova
Posts: 2758
Joined: 27 Jul 2007

Postby Marina Pashkova » 08 Oct 2008

Hi TJ,

There's no difference between the two variants of code whatsoever.

Regards.

RWDickinson
Posts: 43
Joined: 01 Dec 2008
Has thanked: 2 times
Been thanked: 2 times

Postby RWDickinson » 09 Dec 2008

TJ: there is no difference in the result; the reason some programmers do this is that in some languages you can avoid some programmer errors by doing your comparisons this way.

In 'C' language it is a common error to code "if x = 0" (an assignment of value: assigns 0 and the 'if' will always be false) instead of the desired "if x==0" (a comparison). This error code will compile and execute but introduces a hard-to-find bug. However if you make the same equal-sign error by coding "if 0 = x" then the compiler will complain. Hope that was clear. I don't see an advantage in EL, unless you are used to looking at your comparisons in this format.

User avatar
TJ
Posts: 6550
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 965 times
Been thanked: 1892 times

Postby TJ » 09 Dec 2008

thanks for the explanation.
that makes sense.


Return to “MultiCharts”