if/then语句后面可以跟随可选的else语句,该语句在布尔表达式为false时执行。
if/then/ else - 语法
F#编程语言中IF/THEN/ELSE语句的语法是-
if expr then expr else expr
if/then/ else - 流程图

if/then/ else - 示例
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 20Value of a is: 100