if / then語(yǔ)句后面可以有一個(gè)可選的else語(yǔ)句,當(dāng)布爾表達(dá)式為false時(shí)執(zhí)行。
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
當(dāng)編譯和執(zhí)行程序時(shí),它會(huì)產(chǎn)生以下輸出 -
a is not less than 20 Value of a is: 100
更多建議: