syntax of an if-statementは
if_statement ::=
if condition then
sequence_of_statements
{elsif condition then
sequence_of_statements}
[else
sequence_of_statements]
end if;
あり、syntax of “condition”であります
condition ::= boolean_expression
(つまり、真にブール値の式です)。 syntax of “expression”ので、あなたのコードが
if velocity = critical_velocity
and temperature = critical_temperature
and altitude = critical_altitude
then
print ("some message”);
else
null;
end if;
のようになります。あなたはelse
句を残すことができ、そして何らかの理由であなたがチェックしてはならない場合は、and then
代わりの平野and
を言うことができ
expression ::=
relation {and relation} | relation {and then relation}
| relation {or relation} | relation {or else relation}
| relation {xor relation}
です最初の部分が既にFalse
であれば、残りの状態。これは短絡評価と呼ばれ、ではなく、がAdaのデフォルト(C言語)です。
if X /= 0 and Y/X > 2 then
は、Xが0であってもY/X
と評価されます。
if Velocity = Critical_Velocity
and Temperature = Critical_Temperature
and Altitude = Critical_Altitude
then
Ada.Text_IO.Put_Line ("Crash");
else
...
end if;
が評価順序の問題は、あなたが、その後またはまたは他を使用します。
ありがとうサイモン!非常に反復的な内訳、非常に役に立ちます:) – DaveSwans
ここにコメントのためには長すぎたので私がコメントで尋ねることができなかった別の質問へのリンクです。あなたはいくつかの光を発することができれば、それは非常に高く評価されるだろう。 http://stackoverflow.com/questions/36957726/shortened-method-to-reduce-statements-in-an-ada-procedure – DaveSwans