📜  F#布尔运算符

📅  最后修改于: 2021-01-01 04:36:43             🧑  作者: Mango

F#布尔运算符

布尔运算符用于检查条件表达式。如果表达式满足条件,则返回true,否则返回false。在F#运算符计算第二个操作数,如果第一个操作数是真实的,否则返回,不检查第二个操作数错误。它也被称为短路运算符。

Symbol Description
Not Boolean negation
|| Boolean OR
&& Boolean AND

F#布尔运算符示例

let booleanOperator(a:int,b:int) =
    if(a = 10 && b = 10 ) then
        printfn "A and B both are equal"
    if(a = 20 || b = 20) then
        printfn "Either A or B is 20"

booleanOperator(10,10)
booleanOperator(20,11)

输出:

A and B both are equal
Either A or B is 20