Trilean

final
class Trilean(val value: Int) extends AnyVal

Implementation of three-valued logic.

This type resembles Boolean, but has three values instead of two:

  • Trilean.True (equivalent to true)
  • Trilean.False (equivalent to false)
  • Trilean.Unknown

Trilean supports the same operations that Boolean does, and as long as all values are True or False, the results will be the same. However, the truth tables have to be extended to work with unknown:

not:

-+-
T|F
U|U
F|T

and:

 |T U F
-+-----
T|T U F
U|U U F
F|F F F

or:

 |T U F
-+-----
T|T T T
U|T U U
F|T U F

Trilean is implemented as a value type, so in most cases it will only have the overhead of a single Int. However, in some situations it will be boxed.

Companion
object
class AnyVal
trait Matchable
class Any

Value members

Concrete methods

def &(rhs: Trilean): Trilean
def &&(rhs: => Trilean): Trilean
def ^(rhs: Trilean): Trilean
def assume(b: Boolean): Boolean
def assumeFalse: Boolean
def assumeTrue: Boolean
def fold[A](f: Boolean => A)(unknown: => A): A
def imp(rhs: Trilean): Trilean
def isFalse: Boolean
def isKnown: Boolean
def isNotFalse: Boolean
def isNotTrue: Boolean
def isTrue: Boolean
def isUnknown: Boolean
def nand(rhs: Trilean): Trilean
def nor(rhs: Trilean): Trilean
def nxor(rhs: Trilean): Trilean
def toBoolean(b: => Boolean): Boolean
def toOption: Option[Boolean]
override
def toString: String
Definition Classes
Any
def |(rhs: Trilean): Trilean
def ||(rhs: => Trilean): Trilean

Concrete fields

val value: Int