scala / 3.2 / scala / anyref.html

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

final def eq(x$0: Object): Boolean

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 and y of type AnyRef, multiple invocations of x.eq(y) consistently returns true or consistently returns false.

  • For any non-null instance x of type AnyRef, x.eq(null) and null.eq(x) returns false.

  • null.eq(null) returns true.

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
that

the object to compare against this object for reference equality.

Returns

true if the argument is a reference to the receiver object; false otherwise.

final def ne(x$0: Object): Boolean

Equivalent to !(this eq that).

Value parameters
that

the object to compare against this object for reference equality.

Returns

true if the argument is not a reference to the receiver object; false otherwise.

final def notify(): Unit

Wakes up a single thread that is waiting on the receiver object's monitor.

Note

not specified by SLS as a member of AnyRef

final def notifyAll(): Unit

Wakes up all threads that are waiting on the receiver object's monitor.

Note

not specified by SLS as a member of AnyRef

final def synchronized[X0](x$0: X0): X0

Executes the code in body with an exclusive lock on this.

Value parameters
body

the code to execute

Returns

the result of body

final def wait(): Unit

See https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#wait--.

Note

not specified by SLS as a member of AnyRef

final def wait(x$0: Long): Unit

See https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#wait-long-.

Value parameters
timeout

the maximum time to wait in milliseconds.

Note

not specified by SLS as a member of AnyRef

final def wait(x$0: Long, x$1: Int): Unit

See https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#wait-long-int-

Value parameters
nanos

additional time, in nanoseconds range 0-999999.

timeout

the maximum time to wait in milliseconds.

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