Scala Library: scala.Boolean
scala.Boolean
Boolean
(equivalent to Java’s boolean
primitive type) is a subtype of
scala.AnyVal. Instances of Boolean
are not represented by an object in the
underlying runtime system.
There is an implicit conversion from scala.Boolean => scala.runtime.RichBoolean which provides useful non-primitive operations.
Abstract Value Members From scala.Boolean
abstract def !=(x: Boolean): Boolean
Compares two Boolean expressions and returns true
if they evaluate to a
different value.
a != b
returns true
if and only if
a
istrue
andb
isfalse
ora
isfalse
andb
istrue
.
(defined at scala.Boolean)
abstract def &&(x: Boolean): Boolean
Compares two Boolean expressions and returns true
if both of them evaluate to
true.
a && b
returns true
if and only if
-
a
andb
aretrue
. -
Note
- This method uses ‘short-circuit’ evaluation and behaves as if it was
declared as
def &&(x: => Boolean): Boolean
. Ifa
evaluates tofalse
,false
is returned without evaluatingb
.
- This method uses ‘short-circuit’ evaluation and behaves as if it was
declared as
(defined at scala.Boolean)
abstract def &(x: Boolean): Boolean
Compares two Boolean expressions and returns true
if both of them evaluate to
true.
a & b
returns true
if and only if
-
a
andb
aretrue
. -
Note
- This method evaluates both
a
andb
, even if the result is already determined after evaluatinga
.
- This method evaluates both
(defined at scala.Boolean)
abstract def ==(x: Boolean): Boolean
Compares two Boolean expressions and returns true
if they evaluate to the same
value.
a == b
returns true
if and only if
a
andb
aretrue
ora
andb
arefalse
.
(defined at scala.Boolean)
abstract def ^(x: Boolean): Boolean
Compares two Boolean expressions and returns true
if they evaluate to a
different value.
a ^ b returns true if and only if
a
istrue
andb
isfalse
ora
isfalse
andb
istrue
.
(defined at scala.Boolean)
abstract def |(x: Boolean): Boolean
Compares two Boolean expressions and returns true
if one or both of them
evaluate to true.
a | b
returns true
if and only if
a
istrue
orb
istrue
or-
a
andb
aretrue
. - Note
- This method evaluates both
a
andb
, even if the result is already determined after evaluatinga
.
- This method evaluates both
(defined at scala.Boolean)
abstract def ||(x: Boolean): Boolean
Compares two Boolean expressions and returns true
if one or both of them
evaluate to true.
a || b
returns true
if and only if
a
istrue
orb
istrue
or-
a
andb
aretrue
. - Note
- This method uses ‘short-circuit’ evaluation and behaves as if it was
declared as
def ||(x: => Boolean): Boolean
. Ifa
evaluates totrue
,true
is returned without evaluatingb
.
- This method uses ‘short-circuit’ evaluation and behaves as if it was
declared as
(defined at scala.Boolean)
Concrete Value Members From scala.Boolean
abstract def unary_!: Boolean
Negates a Boolean expression.
-
!a
results infalse
if and only ifa
evaluates totrue
and -!a
results intrue
if and only ifa
evaluates tofalse
. -
returns
- the negated expression
(defined at scala.Boolean)
Concrete Value Members From Implicit scala.LowPriorityImplicits.booleanWrapper
def <(that: Boolean): Boolean
Returns true if this
is less than that
- Implicit information
- This member is added by an implicit conversion from Boolean to RichBoolean performed by method booleanWrapper in scala.LowPriorityImplicits.
- Definition Classes
- Ordered
(added by implicit convertion: scala.LowPriorityImplicits.booleanWrapper)
def <=(that: Boolean): Boolean
Returns true if this
is less than or equal to that
.
- Implicit information
- This member is added by an implicit conversion from Boolean to RichBoolean performed by method booleanWrapper in scala.LowPriorityImplicits.
- Definition Classes
- Ordered
(added by implicit convertion: scala.LowPriorityImplicits.booleanWrapper)
def >(that: Boolean): Boolean
Returns true if this
is greater than that
.
- Implicit information
- This member is added by an implicit conversion from Boolean to RichBoolean performed by method booleanWrapper in scala.LowPriorityImplicits.
- Definition Classes
- Ordered
(added by implicit convertion: scala.LowPriorityImplicits.booleanWrapper)
def >=(that: Boolean): Boolean
Returns true if this
is greater than or equal to that
.
- Implicit information
- This member is added by an implicit conversion from Boolean to RichBoolean performed by method booleanWrapper in scala.LowPriorityImplicits.
- Definition Classes
- Ordered
(added by implicit convertion: scala.LowPriorityImplicits.booleanWrapper)
def compare(y: Boolean): Int
Result of comparing this
with operand that
.
Implement this method to determine how instances of A will be sorted.
Returns x
where:
x < 0
whenthis < that
x == 0
whenthis == that
-
x > 0
whenthis > that
- Implicit information
- This member is added by an implicit conversion from Boolean to RichBoolean performed by method booleanWrapper in scala.LowPriorityImplicits.
- Definition Classes
- OrderedProxy → Ordered
(added by implicit convertion: scala.LowPriorityImplicits.booleanWrapper)
def compareTo(that: Boolean): Int
Result of comparing this
with operand that
.
- Implicit information
- This member is added by an implicit conversion from Boolean to RichBoolean performed by method booleanWrapper in scala.LowPriorityImplicits.
- Definition Classes
- Ordered → Comparable
(added by implicit convertion: scala.LowPriorityImplicits.booleanWrapper)
Concrete Value Members From Implicit scala.Predef.boolean2Boolean
def compareTo(arg0: java.lang.Boolean): Int
- Implicit information
- This member is added by an implicit conversion from Boolean to java.lang.Boolean performed by method boolean2Boolean in scala.Predef.
- Definition Classes
- Boolean → Comparable (added by implicit convertion: scala.Predef.boolean2Boolean)
Full Source:
Interested in Scala?
I send out weekly, personalized emails with articles and conference talks.
Subscribe now.