Fsharp-if-else-statement

提供:Dev Guides
移動先:案内検索

F#-if/elseステートメント

*if/then* ステートメントの後にオプションの *else* ステートメントを続けることができます。これはブール式がfalseの場合に実行されます。

構文

F#プログラミング言語のif/then/elseステートメントの構文は-

if expr then
   expr
else
   expr

流れ図

その他のステートメント

let a : int32 = 100

( *check the boolean condition using if statement* )

if (a < 20) then
   printfn "a is less than 20\n"
else
   printfn "a is not less than 20\n"
   printfn "Value of a is: %d" a

あなたがプログラムをコンパイルして実行すると、次の出力が得られます-

a is not less than 20

Value of a is: 100