![]() |
| ||||||||||||
Navigation |
Synopsis Conditional statement.
Syntax
Types
Description The test
Exp is evaluated and its outcome determines the statement to be executed:
Statement1 if Exp yields true and Statement2 otherwise.
The value of an if-then statement is equal to Statement when its test is true. Otherwise it is void.
The value of an if-then-else statement is the value of the statement that was executed.
Examples
rascal>if( 3 > 2 ) 30; else 40; int: 30 rascal>x = if( 3 > 2 ) 30; else 40; int: 30 rascal>if( 3 > 2 ) 30; int: 30An if-then statement yields void when its test is false
(demonstrated by the ok that is printed by the Rascal system):
rascal>if( 2 > 3 ) 30;
ok
Questions
Question [1].
![]() ![]()
Question [2].
![]() ![]()
Question [3].
![]() ![]() ![]() |