在阿達您將使用和,或和不布爾運算符:
if Velocity = Critical_Velocity
and Temperature = Critical_Temperature
and Altitude = Critical_Altitude
then
Ada.Text_IO.Put_Line ("Crash");
else
...
end if;
當評估順序的問題,您將使用然後或否則語法(否則編譯器可以改變優化順序)。 表達式將在'然後'/'或其他'順序中進行評估。
if Velocity = Critical_Velocity
and then Temperature = Critical_Temperature
and then Altitude = Critical_Altitude
then
Ada.Text_IO.Put_Line ("Crash");
else
...
end if;
隨着否則,你可以寫如下:
if Velocity = Critical_Velocity
or else Temperature = Critical_Temperature
or else Altitude = Critical_Altitude
then
Ada.Text_IO.Put_Line ("Crash");
else
...
end if;
要注意的是,你不能混用和和或在一起(因爲這會導致許多混亂的開發者) 。 如果你這樣做,你必須使用圓括號。
if (Velocity = Critical_Velocity and Temperature = Critical_Temperature)
or else 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