观看 Martin Odersky 的 scala 课程的第 4.2 节课,我无法理解以下课程或其用途:
abstract class Boolean {
def ifThenElse[T](t: => T, e: => T): T
def && (x: => Boolean): Boolean = ifThenElse(x, False)
def || (x: => Boolean): Boolean = ifThenElse(True, x)
def unary_! : Boolean = ifThenElse(False , True)
def == (x: Boolean): Boolean = ifThenElse(x, x.unary_!)
def != (x: Boolean): Boolean = ifThenElse(x.unary_! , x)
object False extends Boolean {
def ifThenElse[T](t: => T, e: => T) = e
}
object True extends Boolean {
def ifThenElse[T](t: => T, e: => T) = e
}
}
是否可以提供示例实施/解释,以便我可以更好地提供正在发生的事情和/或其用途?