Fsharp-if-elif-else-statement
提供:Dev Guides
F#-if/elif/elseステートメント
*if/then/elif/else* コンストラクトには複数のelseブランチがあります。
構文
F#プログラミング言語のif/then/elif/elseステートメントの構文は-
if expr then
expr
elif expr then
expr
elif expr then
expr
...
else
expr
例
let a : int32 = 100
( *check the boolean condition using if statement* )
if (a = 10) then
printfn "Value of a is 10\n"
elif (a = 20) then
printfn " Value of a is 20\n"
elif (a = 30) then
printfn " Value of a is 30\n"
else
printfn " None of the values are matching\n"
printfn "Value of a is: %d" a
あなたがプログラムをコンパイルして実行すると、次の出力が得られます-
None of the values are matching
Value of a is: 100