_methods

trait _methods

Boolean Extension Methods

Extension methods universaly avaialble for type scala.Boolean

Source
_methods.scala
class java.lang.Object
trait scala.Matchable
class Any

Def

@scala.annotation.targetName("Opt")
inline def ?: Boolean.Opt

To option

To option

Returns Boolean.Opt for current value

 val o: Boolean.Opt = true.?
Source
_methods.scala
@scala.annotation.targetName("Opt")
inline def ?[A](inline v: => A): Opt[A]

To given value option

To given value option

Returns given value option if base Boolean is true, and void option if false

 var b = true

 (b ? "Foo").tp  // Prints   Opt(Foo)

 b = false

 (b ? "Foo").tp  // Prints   Opt(\/)

Note: This operation can be used as a conditional function

 var b = true

 (b ? "Foo" or "Bar").tp  // Prints   Foo

 b = false

 (b ? "Foo" or "Bar").tp  // Prints   Bar
Source
_methods.scala
inline def not: Boolean

Reversed Boolean

Reversed Boolean

This is a postfix operation equivalent to !, ie. true.not == !true

 var b = true

 b.not  // Prints   false

 b = false

 b.not  // Prints   true

Note: This operation is inlined and can be used without performance worries

Source
_methods.scala

Make

inline def Int: Int

Make Int

Make Int

Int constructor attached to Boolean

true is converted to 1, false to 0

Source
_methods.scala