Elixir-decision-unless

提供:Dev Guides
2020年6月22日 (月) 22:53時点におけるMaintenance script (トーク | 投稿記録)による版 (Imported from text file)
(差分) ← 古い版 | 最新版 (差分) | 新しい版 → (差分)
移動先:案内検索

Elixir-声明以外の場合

exceptステートメントは、ブール式とそれに続く1つ以上のステートメントで構成されます。

構文

exceptステートメントの構文は次のとおりです-

unless boolean-statement do
   #Code to be executed if condition is false
end

ブール式の評価が false の場合、unlessステートメント内のコードブロックが実行されます。 ブール式がtrueに評価される場合、指定されたステートメントのendキーワードの後の最初のコードセットが実行されます。

a = false
unless a === true do
   IO.puts "Condition is not satisfied"
   IO.puts "So this code block is executed"
end
IO.puts "Outside the unless statement"

上記のプログラムは、次の結果を生成します-

Condition is not satisfied
So this code block is executed
Outside the unless statement