F#中嵌套if语句
2018-12-15 09:43 更新
在F#编程中总是合法的,如果/ then或if / then / else语句,这意味着你可以在另一个if或else if语句中使用一个if或else语句。
语法
if expr then
expr
if expr then
expr
else
expr
else
expr
实例
let a : int32 = 100
let b : int32 = 200
(* check the boolean condition using if statement *)
if (a = 100) then
(* if condition is true then check the following *)
if (b = 200) then
printfn "Value of a is 100 and b is 200\n"
printfn "Exact value of a is: %d" a
printfn "Exact value of b is: %d" b编译和执行程序时,将产生以下输出
Value of a is 100 and b is 200 Exact value of a is: 100 Exact value of b is: 200
以上内容是否对您有帮助:

免费 AI IDE


更多建议: