7.7 Conditional Statements
Stan supports full conditional statements using the same if-then-else syntax as C++. The general format is
if (condition1)
statement1
else if (condition2)
statement2
// ...
else if (conditionN-1)
statementN-1
else
statementN
There must be a single leading if
clause, which may be followed
by any number of else if
clauses, all of which may be
optionally followed by an else
clause. Each condition must be
a real or integer value, with non-zero values interpreted as true and
the zero value as false.
The entire sequence of if-then-else clauses forms a single conditional statement for evaluation. The conditions are evaluated in order until one of the conditions evaluates to a non-zero value, at which point its corresponding statement is executed and the conditional statement finishes execution. If none of the conditions evaluates to a non-zero value and there is a final else clause, its statement is executed.