BoolExt extension

  • @Author: chuxiong
  • @Created at: 2023/3/2 4:05 下午
  • @Email:
  • @Company: 嘉联支付
  • description bool 扩展:提供取反、逻辑运算、条件取值与类型转换等便捷方法。
on

Properties

not → bool

Available on bool, provided by the BoolExt extension

逻辑取反(等价于 !this,便于链式调用)。
no setter
toInt → int

Available on bool, provided by the BoolExt extension

转为整数:true → 1,false → 0。
no setter
toStringVal → String

Available on bool, provided by the BoolExt extension

转为字符串:'true' / 'false'(与 toString() 等价的语义化别名)。
no setter

Methods

ifElse<T>(T ifTrueValue, T ifFalseValue) → T

Available on bool, provided by the BoolExt extension

条件返回值:true 返回 ifTrueValue,false 返回 ifFalseValue。
ifFalse<T>(T value) → T?

Available on bool, provided by the BoolExt extension

当本值为 false 时返回 value,否则返回 null。
ifTrue<T>(T value) → T?

Available on bool, provided by the BoolExt extension

当本值为 true 时返回 value,否则返回 null。

Operators

operator &(bool other) → bool

Available on bool, provided by the BoolExt extension

逻辑与(等价于 this && other,可用作中缀运算符 a & b)。
operator |(bool other) → bool

Available on bool, provided by the BoolExt extension

逻辑或(等价于 this || other,可用作中缀运算符 a | b)。