目录

if/then/ else statement

if/then语句后面可以跟一个可选的else语句,该语句在布尔表达式为false时执行。

语法 (Syntax)

F#编程语言中if/then/else语句的语法是 -

if expr then
   expr
else
   expr

流程图 (Flow Diagram)

其他声明

例子 (Example)

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
↑回到顶部↑
WIKI教程 @2018