_methods
trait _methods
Boolean Extension Methods
Extension methods universaly avaialble for type scala.Boolean
- Source
- _methods.scala
Def
@targetName("Opt")
To option
To option
Returns Boolean.Opt for current value
val o: Boolean.Opt = true.?
- Source
- _methods.scala
@targetName("Opt")
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(VOID)
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
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 Int
Make Int
Int constructor attached to Boolean
true
is converted to 1
, false
to 0
- Source
- _methods.scala
To Boolean object
To Boolean object
val b = true
b.toRef
// is inlined as
java.lang.Boolean.valueOf(b)
- Source
- _methods.scala