897 bytes added
, 18:24, May 4, 2009
A '''test for equality''' in computer programming is one of the trickiest tests used to control a computer program. The usual syntax is something like:
IF (''test'') THEN
... ''do something''
ELSE
... ''do something else''
END IF
or in the curly brace languages like Java, C (etc.) or PHP:
if (''test'') {
... ''do something''
}
else {
... ''do something else''
}
The tricky part is the ''test'' syntax. You can simply write x > 4 with no problem (see [[test for inequality]]), but if you check for x = 4 you could have a disastrous side effect.
The curly brace languages all require a [[double equal sign]] to be used for tests. This may look strange to the beginner, but it distinguishes an [[assignment]] from a [[test]]. If you use a [[single equal sign]] your code may still compile and run, but your results will probably be incorrect.
[[category:Computer Programming]]