Level 0, lesson 19

# 0.19 IF-ELSE constructs

Like most other languages you can use IF-ELSE constructs. Let's enhance our previous example:

         variable var
         4 var !

         var @ 5 >
         if ." Greater" cr
         else ." Less or equal" cr
         then

So now our program does the job. It tells you when it's greater and when not. Note that contrary to other languages the condition comes before the 'IF' and 'THEN' ends the IF-clause. In other words, whatever path the program takes, it always continues after the 'THEN'. A tip: think of 'THEN' as 'ENDIF'..