F#中if/else语句
2018-12-15 09:45 更新
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
以上内容是否对您有帮助:
更多建议: