F# 中的 if /then 语句函数

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

if/then语句由一个布尔表达式后跟一个或多个语句组成。

if /then - 语法

F#中的if/then构造具有以下语法-

(* simple if *)
if expr then
   expr

if /then - 流程图

If then Statement

if /then - 示例

let a : int32=10

(* check the boolean condition using if statement *)
if (a < 20) then
   printfn "a is less than 20\n"
   printfn "Value of a is: %d" a

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

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

来源:LearnFk无涯教程网

a is less than 20

Value of a is: 10

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

技术教程推荐

Android开发高手课 -〔张绍文〕

数据分析实战45讲 -〔陈旸〕

重学前端 -〔程劭非(winter)〕

图解 Google V8 -〔李兵〕

正则表达式入门课 -〔涂伟忠〕

物联网开发实战 -〔郭朝斌〕

业务开发算法50讲 -〔黄清昊〕

深入浅出分布式技术原理 -〔陈现麟〕

结构思考力 · 透过结构看表达 -〔李忠秋〕

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