Movatterモバイル変換


[0]ホーム

URL:


do-whileswitch

5.16 if

Conditional expressions come in the form of a leadingif keyword, a condition expression enclosed in parentheses() and a expression to be evaluated in case the condition holds:

if (condition)expression;

The condition expression has to be of typeBool.

Optionally,expression may be followed by theelse keyword as well as another expression to be evaluated if the condition does not hold:

if (condition)expression1elseexpression2;

Here,expression2 may consist of anotherif expression:

if (condition1)expression1elseif (condition2)expression2elseexpression3

If the value of anif expression is required, e.g. forvar x = if(condition) expression1 else expression2, the typer ensures that the types ofexpression1 andexpression2unify. If noelse expression is given, the type is inferred to beVoid.



[8]ページ先頭

©2009-2025 Movatter.jp