F# 中的 if/then/elif/else 语句函数

首页 / F#入门教程 / F# 中的 if/then/elif/else 语句函数

If/Then/Elif/Else构造有多个Else分支。

if/then/elif/else - 语法

F#编程语言中IF/THEN/ELIF/ELSE语句的语法是-

if expr then
   expr
elif expr then
   expr
elif expr then
   expr
...
else
   expr

if/then/elif/else - 示例

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

当您编译并执行程序时,它会生成以下输出-

链接:https://www.learnfk.comhttps://www.learnfk.com/fsharp/fsharp-if-elif-else-statement.html

来源:LearnFk无涯教程网

None of the values are matching

Value of a is: 100

祝学习愉快!(内容编辑有误?请选中要编辑内容 -> 右键 -> 修改 -> 提交!)

技术教程推荐

深入浅出区块链 -〔陈浩〕

浏览器工作原理与实践 -〔李兵〕

分布式技术原理与算法解析 -〔聂鹏程〕

跟月影学可视化 -〔月影〕

动态规划面试宝典 -〔卢誉声〕

大厂晋升指南 -〔李运华〕

体验设计案例课 -〔炒炒〕

Spark性能调优实战 -〔吴磊〕

全链路压测实战30讲 -〔高楼〕

好记忆不如烂笔头。留下您的足迹吧 :)