All Downloads are FREE. Search and download functionalities are using the official Maven repository.

mouse.boolean.scala Maven / Gradle / Ivy

There is a newer version: 0.10-MF
Show newest version
package mouse

trait BooleanSyntax {
  implicit final def booleanSyntaxMouse(b: Boolean): BooleanOps = new BooleanOps(b)
}

final class BooleanOps(val b: Boolean) extends AnyVal {

  final def option[A](a: => A): Option[A] = fold(Some(a), None)

  @deprecated("Use `either` instead", "0.6")
  final def xor[L, R](l: =>L, r: =>R): Either[L, R] = either(l, r)

  final def either[L, R](l: =>L, r: =>R): Either[L, R] = fold(Right(r), Left(l))

  final def fold[A](t: => A, f: => A): A = if (b) t else f

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy