Fsharp-if-else-statement

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

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