Delphi coding hints and tips.
Conditional assignment of a boolean variable.
When assigning a boolean variable based on some condition it is not necessary to use a IF THEN statement. For example:-
if ((x=0)and(y=0)) then AtOrigin:=True else AtOrigin:=False;
Instead of the IF THEN just assign the boolean to the result of the conditional evaluation like so:-
AtOrigin:=((x=0)AND(y=0));
Not only does this reduce the amount of code but will execute faster once compiled.


