F#中if/elif/else语句
2018-12-15 09:46 更新
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
以上内容是否对您有帮助:
更多建议: