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
祝学习愉快!(内容编辑有误?请选中要编辑内容 -> 右键 -> 修改 -> 提交!)