Elixir-decision-unless
提供:Dev Guides
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