Fsharp-if-statement

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

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

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

構文

F#のif/thenコンストラクトの構文は次のとおりです-

( *simple if* )
if expr then
   expr

流れ図

If thenステートメント

let a : int32 = 10

( *check the boolean condition using if statement* )
if (a < 20) then
   printfn "a is less than 20\n"
   printfn "Value of a is: %d" a

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

a is less than 20

Value of a is: 10