- 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# - 基本 I/O
- F# - 泛型
- F# - 委托
- F# - 枚举
- F# - 模式匹配
- F# - 异常处理
- F# - 类
- F# - 结构
- F# - 运算符重载
- F# - 继承
- F# - 接口
- F# - 事件
- F# - 模块
- F# - 命名空间
F# - if/elif/else 语句
if/then/elif/else 结构有多个 else 分支。
语法
F# 编程语言中 if/then/elif/else 语句的语法为:-
if expr then expr elif expr then expr elif expr then expr ... else expr
示例
let a : int32 = 100 (* check the boolean condition using if statement *) if (a = 10) then printfn "Value of a is 10\n" elif (a = 20) then printfn " Value of a is 20\n" elif (a = 30) then printfn " Value of a is 30\n" else printfn " None of the values are matching\n" printfn "Value of a is: %d" a
编译并执行程序后,将生成以下输出:-
None of the values are matching Value of a is: 100
fsharp_decision_making.htm
广告