%if A == B %then %warning "A and B are the same" %elseif B == C %then %warning "A is not equal to B, but B and C are the same" %elseif C == D %then %warning "A is not equal to B, nor B is equal to C, but C and D are the same" %elseif ANumericVar %then %warning "ANumericVar is not zero" %elseif AnObjectVar %then %warning "AnObjectVar is not %null" %elseif AListVar %then %warning "AListVar is not empty" %elseif AStringVar %then $ ILLEGAL – strings are not convertible to Boolean $ will raise an error at runtime ... %else %warning "None of the above conditions was met" %endif
The %elseif keyword simplifies conditional paths.
Arguments of conditions can be as follows:
• Comparison results returned by ==, !=, >=, etc.
• Logical tests returns by %hasstereotype, %inlist, %matchcase, etc.
• Numeric values (0 = false, otherwise true)
• Object values (%null = false, otherwise true)
• List values (empty list = false, otherwise true)