Skip to content

Latest commit

 

History

History
58 lines (40 loc) · 838 Bytes

Conditionals.md

File metadata and controls

58 lines (40 loc) · 838 Bytes

if

Description:
Executes a command if the condition is true.

Syntax:

if <condition> <command>

Example:

if (lt 10 20) (print 10 < 20)

Result:

10 < 20

if-else

ife

Description:
Executes a command if the condition is true, otherwise executes another command.

Syntax:

if <condition> <command> else <command>

Example:

if (lt 10 20) (print 10 < 20) else (print 10 >= 20)

Result:

ASRuntimeError
Reason: The command 'if' expects 2 arguments, but found 4.

if (lt 10 20) (print 10 < 20) else (print 10 >= 20)
└> if <-- Here
   ├>lt
     ├ 10
     ├ 20
   ├>print
     ├ 10
     ├ <
     ├ 20
   ├ else
   ├>print
     ├ 10
     ├ >=
     ├ 20