On this page
Class AnyRef.AnyRef
class AnyRef
Class AnyRef
is the root class of all reference types. All types except the value types descend from this class.
Known subtypes |
350 types |
---|
Concrete methods
Tests whether the argument (that
) is a reference to the receiver object (this
).
The eq
method implements an equivalence relation on non-null instances of AnyRef
, and has three additional properties:
It is consistent: for any non-null instances
x
andy
of typeAnyRef
, multiple invocations ofx.eq(y)
consistently returnstrue
or consistently returnsfalse
.For any non-null instance
x
of typeAnyRef
,x.eq(null)
andnull.eq(x)
returnsfalse
.null.eq(null)
returnstrue
.
When overriding the equals
or hashCode
methods, it is important to ensure that their behavior is consistent with reference equality. Therefore, if two objects are references to each other (o1 eq o2
), they should be equal to each other (o1 == o2
) and they should hash to the same value (o1.hashCode == o2.hashCode
).
Value parameters |
|
---|---|
Returns |
|
Equivalent to !(this eq that)
.
Value parameters |
|
---|---|
Returns |
|
Wakes up a single thread that is waiting on the receiver object's monitor.
Note | not specified by SLS as a member of AnyRef |
---|
Wakes up all threads that are waiting on the receiver object's monitor.
Note | not specified by SLS as a member of AnyRef |
---|
Executes the code in body
with an exclusive lock on this
.
Value parameters |
|
---|---|
Returns | the result of |
See https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#wait--.
Note | not specified by SLS as a member of AnyRef |
---|
See https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#wait-long-.
Value parameters |
|
---|---|
Note | not specified by SLS as a member of AnyRef |
See https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#wait-long-int-
Value parameters |
|
---|---|
Note | not specified by SLS as a member of AnyRef |
© 2002-2022 EPFL, with contributions from Lightbend.
Licensed under the Apache License, Version 2.0.
https://scala-lang.org/api/3.2.0/scala/AnyRef.html