- F# 基本教程
- F# - 首页
- F# - 概览
- F# - 环境设置
- F# - 程序结构
- F# - 基本语法
- F# - 数据类型
- F# - 变量
- F# - 运算符
- F# - 决策制定
- F# - 循环
- F# - 函数
- F# - 字符串
- F# - 选项
- F# - 元组
- F# - 记录
- F# - 列表
- F# - 序列
- F# - 集合
- F# - 映射
- F# - 区分的联合
- F# - 可变数据
- F# - 数组
- F# - 可变列表
- F# - 可变字典
- F# - 基本输入/输出
- F# - 泛型
- F# - 委托
- F# - 枚举
- F# - 模式匹配
- F# - 异常处理
- F# - 类
- F# - 结构
- F# - 运算符重载
- F# - 继承
- F# - 接口
- F# - 事件
- F# - 模块
- F# - 命名空间
F# - 嵌套 if 语句
在 F# 编程中,始终可以嵌套 if/then 或 if/then/else 语句,这意味着你可以在另一个 if 或 else if 语句内使用一个 if 或 else if 语句。
语法
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
fsharp_decision_making.htm
广告