An if object is a
conditional statement. When executed, it will execute the if<-condition.
On success, it will execute the if<-then
branch, otherwise it will execute the if<-else
branch. An empty if<-then
or if<-else
(@nil) simply
succeeds.
A special trick is to use if(<Statement>). This
will succeed regardless of the success or failure of <Statement>.
The following example exploits the if
object to remove all graphicals with area<-measure
from Device:
send(Device?graphicals, for_all,
if(@arg1?area?measure == 0,
message(@arg1, free)))
Class when implements the function equivalent of class if.
->execute.<-then
is executed on successful execution of if<-condition, if<-else
otherwise. If the statement is @nil,
it executes successfully without side-effects. If the statement is a
function, it will be executed as defined by code->execute.-else