if/then语句由一个布尔表达式后跟一个或多个语句组成。
F#中的if/then构造具有以下语法-
(* simple if *) if expr then expr
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
祝学习愉快!(内容编辑有误?请选中要编辑内容 -> 右键 -> 修改 -> 提交!)