Any

scala.Any
abstract transparent open class Any

Class Any is the root of the Scala class hierarchy. Every class in a Scala execution environment inherits directly or indirectly from this class.

Starting with Scala 2.10 it is possible to directly extend Any using ''universal traits''. A ''universal trait'' is a trait that extends Any, only has defs as members, and does no initialization.

The main use case for universal traits is to allow basic inheritance of methods for value classes. For example,

   trait Printable extends Any {
     def print(): Unit = println(this)
   }
   class Wrapper(val underlying: Int) extends AnyVal with Printable

   val w = new Wrapper(3)
   w.print()

See the Value Classes and Universal Traits for more details on the interplay of universal traits and value classes.

Attributes

Graph
Known subtypes
trait {}
trait Capability
trait Stateful
trait Mutable
trait Read
trait Var[T]
trait Separate
trait Unscoped
trait Exists
trait Control
class Label[T]
class CanThrow[E]
object any
object cap
object fresh
trait Pure
trait MapOps[K, V, CC, C]
trait Map[K, V]
class AbstractMap[K, V]
class HashMap[K, V]
class IntMap[T]
class ListMap[K, V]
class LongMap[T]
class Map1[K, V]
class Map2[K, V]
class Map3[K, V]
class Map4[K, V]
class WithDefault[K, V]
class WithDefault[K, V]
class TreeMap[K, V]
class TreeSeqMap[K, V]
class VectorMap[K, V]
trait SeqMap[K, V]
trait SortedMap[K, V]
trait SortedMapOps[K, V, CC, C]
trait StrictOptimizedSortedMapOps[K, V, CC, C]
trait StrictOptimizedMapOps[K, V, CC, C]
trait SeqOps[A, CC, C]
trait IndexedSeqOps[A, CC, C]
class ArraySeq[A]
class ofBoolean
class ofByte
class ofChar
class ofDouble
class ofFloat
class ofInt
class ofLong
class ofRef[T]
class ofShort
class ofUnit
trait IndexedSeq[A]
class NumericRange[T]
class Exclusive[T]
class Inclusive[T]
class Range
class Exclusive
class Inclusive
class Vector[A]
trait LinearSeqOps[A, CC, C]
class LazyList[A]
trait LinearSeq[A]
class List[A]
class ::[A]
object Nil
class Queue[A]
class Stream[A]
class Cons[A]
object Empty
trait Seq[A]
class AbstractSeq[A]
trait StrictOptimizedSeqOps[A, CC, C]
trait MapOps[K, V, CC, C]
class TrieMap[K, V]
class AnyRefMap[K, V]
class CollisionProofHashMap[K, V]
class HashMap[K, V]
class LinkedHashMap[K, V]
class ListMap[K, V]
class LongMap[V]
trait Map[K, V]
trait Map[K, V]
class AbstractMap[K, V]
class WithDefault[K, V]
class WithDefault[K, V]
class OpenHashMap[Key, Value]
class TreeMap[K, V]
trait MultiMap[K, V]
trait SeqMap[K, V]
trait SortedMap[K, V]
trait SortedMapOps[K, V, CC, C]
trait SeqOps[A, CC, C]
trait Buffer[A]
class AbstractBuffer[A]
class ArrayBuffer[A]
class ArrayDeque[A]
class Queue[A]
class Stack[A]
class ListBuffer[A]
class UnrolledBuffer[T]
trait IndexedBuffer[A]
trait IndexedSeqOps[A, CC, C]
class ArraySeq[T]
class ofBoolean
class ofByte
class ofChar
class ofDouble
class ofFloat
class ofInt
class ofLong
class ofRef[T]
class ofShort
class ofUnit
trait IndexedSeq[T]
trait Seq[A]
class AbstractSeq[A]
class Accumulator[A, CC, C]
class AnyAccumulator[A]
trait EvidenceIterableFactory[CC, Ev]
class Delegate[CC]
class Delegate[CC]
trait ClassTagSeqFactory[CC]
object ArraySeq
object ArraySeq
class Delegate[CC, Ev]
class Delegate[CC]
object SortedSet
object SortedSet
object SortedSet
object TreeSet
object PriorityQueue
object TreeSet
trait IterableFactory[CC]
object HashSet
object ListSet
object Set
object HashSet
object LinkedHashSet
class AnySeqDelegate[CC]
class Delegate[CC]
object Iterable
object Iterable
object Set
object Iterable
object Set
object Iterator
trait SeqFactory[CC]
object LazyList
object Stream
class Delegate[CC]
object IndexedSeq
object LinearSeq
object Seq
object Buffer
object IndexedBuffer
object IndexedSeq
object Seq
object IndexedSeq
object LinearSeq
object Seq
object List
object Queue
object Vector
object ArrayBuffer
object ArrayDeque
object ListBuffer
object Queue
object Stack
object View
trait LinearSeqOps[A, CC, C]
trait LinearSeq[A]
trait StrictOptimizedLinearSeqOps[A, CC, C]
trait Map[K, V]
class AbstractMap[K, V]
trait DefaultMap[K, V]
trait SeqMap[K, V]
trait SortedMap[K, V]
trait Seq[A]
class AbstractSeq[A]
trait IndexedSeq[A]
trait Set[A]
trait Set[A]
class AbstractSet[A]
class BitSet
class BitSet1
class BitSet2
class BitSetN
class HashSet[A]
class ListSet[A]
class Set1[A]
class Set2[A]
class Set3[A]
class Set4[A]
class TreeSet[A]
class Enumeration.this.ValueSet
trait SortedSet[A]
trait Set[A]
class AbstractSet[A]
class BitSet
class HashSet[A]
class LinkedHashSet[A]
class TreeSet[A]
trait SortedSet[A]
class AbstractSet[A]
trait SortedSet[A]
trait BitSet
trait SetOps[A, CC, C]
trait SetOps[A, CC, C]
trait SortedSetOps[A, CC, C]
trait StrictOptimizedSortedSetOps[A, CC, C]
trait StrictOptimizedSetOps[A, CC, C]
trait SetOps[A, CC, C]
trait SortedSetOps[A, CC, C]
trait SortedSetOps[A, CC, C]
trait BitSetOps[C]
trait SortedSetFactoryDefaults[A, CC, WithFilterCC]
trait StrictOptimizedSortedSetOps[A, CC, C]
trait StrictOptimizedSetOps[A, CC, C]
trait SortedMapFactoryDefaults[K, V, CC, WithFilterCC, UnsortedCC]
trait SortedMapOps[K, V, CC, C]
trait StrictOptimizedSortedMapOps[K, V, CC, C]
trait StrictOptimizedSeqOps[A, CC, C]
trait ArrayDequeOps[A, CC, C]
trait BuildFrom[From, A, C]
trait Factory[A, C]
object BitSet
object WrappedString
object BitSet
object BitSet
object Enumeration.this.ValueSet
trait IndexedSeqOps[A, CC, C]
trait IndexedSeqView[A]
class ArrayBufferView[A]
class Slice[A]
class StringView
class Appended[A]
class Concat[A]
class Drop[A]
class DropRight[A]
class Id[A]
class Map[A, B]
class Prepended[A]
class Reverse[A]
class Take[A]
class TakeRight[A]
trait IterableOnce[A]
trait Iterable[A]
trait Iterable[A]
class LazyListIterable[A]
trait Iterable[A]
class AbstractIterable[A]
class PriorityQueue[A]
class AbstractIterable[A]
class AbstractView[A]
class AbstractMapView[K, V]
class Filter[K, V]
class FilterKeys[K, V]
class Id[K, V]
class MapValues[K, V, W]
class TapEach[K, V, U]
class AbstractSeqView[A]
class Id[A]
class Reverse[A]
class Appended[A]
class Appended[A]
class Collect[A, B]
class Concat[A]
class Concat[A]
class DistinctBy[A, B]
class Drop[A]
class Drop[A]
class DropRight[A]
class DropRight[A]
class DropWhile[A]
class Elems[A]
object Empty
class Fill[A]
class Filter[A]
class FlatMap[A, B]
class Iterate[A]
class LeftPartitionMapped[A, A1, A2]
class Map[A, B]
class Map[A, B]
class PadTo[A]
class Prepended[A]
class Prepended[A]
class RightPartitionMapped[A, A1, A2]
class ScanLeft[A, B]
class Single[A]
class Tabulate[A]
class Take[A]
class Take[A]
class TakeRight[A]
class TakeRight[A]
class TakeWhile[A]
class Unfold[A, S]
class Updated[A]
class Zip[A, B]
class ZipAll[A, B]
class ZipWithIndex[A]
trait View[A]
trait MapView[K, V]
trait SeqView[A]
class Sorted[A, B]
trait IterableOps[A, CC, C]
trait MapFactoryDefaults[K, V, CC, WithFilterCC]
class WeakHashMap[K, V]
trait MapOps[K, V, CC, C]
trait StrictOptimizedMapOps[K, V, CC, C]
trait SeqOps[A, CC, C]
trait StrictOptimizedIterableOps[A, CC, C]
trait Iterator[A]
class AbstractIterator[A]
class Iterator.this.GroupedIterator[B]
class Iterator.this.GroupedIterator[B]
class Source.this.LineIterator
trait BufferedIterator[A]
class Source
class Option[A]
object None
class Some[A]
trait IterableOnceOps[A, CC, C]
class DurationInt
class DurationLong
trait Equiv[T]
object BigDecimal
object BigInt
object Boolean
object Byte
object Char
trait IeeeEquiv
object IeeeEquiv
trait StrictEquiv
object StrictEquiv
trait IeeeEquiv
object IeeeEquiv
trait StrictEquiv
object StrictEquiv
object Int
object Long
object Short
object String
object Symbol
object Unit
trait PartialOrdering[T]
trait Ordering[T]
trait Numeric[T]
trait Fractional[T]
trait Integral[T]
object IntIsIntegral
object BigDecimal
object BigInt
object Boolean
trait ByteOrdering
object Byte
trait CachedReverse[T]
object Int
trait CharOrdering
object Char
trait IeeeOrdering
object IeeeOrdering
object TotalOrdering
trait IeeeOrdering
object IeeeOrdering
object TotalOrdering
trait IntOrdering
trait LongOrdering
object Long
trait OptionOrdering[T]
object Short
object String
object Symbol
trait UnitOrdering
object Unit
trait Ordered[A]
class Deadline
class Duration
class Infinite
class BigDecimal
class Enumeration.this.Value
class Enumeration.this.Val
class BigInt
trait OrderedProxy[T]
class RichBoolean
trait ScalaNumberProxy[T]
trait FractionalProxy[T]
class RichDouble
class RichFloat
class RichInt
trait IntegralProxy[T]
class RichChar
class RichLong
class RichByte
class RichShort
trait PartiallyOrdered[A]
trait Enum
trait RangedProxy[T]
trait ZippedIterable2[El1, El2]
class Tuple2Zipped[El1, It1, El2, It2]
trait ZippedIterable3[El1, El2, El3]
class Tuple3Zipped[El1, It1, El2, It2, El3, It3]
class AnyVal
class Deferrer[A]
class Deferrer[A]
class Partial[T, U]
class Deferrer[A]
class UnwrapOp
class ArrayOps[A]
class SearchImpl[Repr, A]
class Shape
class StringOps
class DoubleMult
class IntMult
class LongMult
class RichBiFunctionAsFunction2[T, U, R]
class RichFunction2AsBiFunction[T, U, R]
class FutureOps[T]
class RichOption[A]
class RichOptional[A]
class Ops[T1, T2]
class Ops[T1, T2, T3]
class ChainingOps[A]
class MergeableEither[A]
class Boolean
class Byte
class Char
class Double
class Float
class UnliftOps[A, B]
class Int
class Long
class ElementWiseExtractor[A, B]
class ArrowAssoc[A]
class Ensuring[A]
class StringFormat[A]
class any2stringadd[A]
class Short
class Unit
class ValueOf[T]
trait Dynamic
trait Equals
class AnyValManifest[T]
trait ClassTag[T]
trait Manifest[T]
trait Product
trait EnumValue
class TupleXXL
class Either[A, B]
class Left[A, B]
class Right[A, B]
class Try[T]
class Failure[T]
class Success[T]
trait Product1[T1]
class Tuple1[T1]
trait Product10[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10]
class (T1, T2, T3, T4, T5, T6, T7, T8, T9, T10)
trait Product11[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11]
class (T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11)
trait Product12[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12]
class (T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12)
trait Product13[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13]
class (T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13)
trait Product14[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14]
class (T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14)
trait Product15[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15]
class (T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15)
trait Product16[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16]
class (T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16)
trait Product17[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17]
class (T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17)
trait Product18[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18]
class (T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18)
trait Product19[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19]
class (T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19)
trait Product2[T1, T2]
class (T1, T2)
trait Product20[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20]
class (T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20)
trait Product21[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, T21]
class (T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, T21)
trait Product22[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22]
class (T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22)
trait Product3[T1, T2, T3]
class (T1, T2, T3)
trait Product4[T1, T2, T3, T4]
class (T1, T2, T3, T4)
trait Product5[T1, T2, T3, T4, T5]
class (T1, T2, T3, T4, T5)
trait Product6[T1, T2, T3, T4, T5, T6]
class (T1, T2, T3, T4, T5, T6)
trait Product7[T1, T2, T3, T4, T5, T6, T7]
class (T1, T2, T3, T4, T5, T6, T7)
trait Product8[T1, T2, T3, T4, T5, T6, T7, T8]
class (T1, T2, T3, T4, T5, T6, T7, T8)
trait Product9[T1, T2, T3, T4, T5, T6, T7, T8, T9]
class (T1, T2, T3, T4, T5, T6, T7, T8, T9)
trait Tuple
object EmptyTuple
class H *: T
trait Proxy
trait ReferenceWrapper[T]
class PhantomReference[T]
class SoftReference[T]
class WeakReference[T]
trait Typed[T]
trait Selectable
trait Selectable
Show all

Members list

Value members

Concrete methods

final def !=(x$0: Any): Boolean

Test two objects for inequality.

Test two objects for inequality.

Value parameters

that

the object to compare against this object for equality.

Attributes

Returns

true if !(this == that), false otherwise.

final def ##: Int

Equivalent to x.hashCode except for boxed numeric types and null. For numerics, it returns a hash value which is consistent with value equality: if two value type instances compare as true, then ## will produce the same hash value for each of them. For null returns a hashcode where null.hashCode throws a NullPointerException.

Equivalent to x.hashCode except for boxed numeric types and null. For numerics, it returns a hash value which is consistent with value equality: if two value type instances compare as true, then ## will produce the same hash value for each of them. For null returns a hashcode where null.hashCode throws a NullPointerException.

Attributes

Returns

a hash value consistent with ==

final def ==(x$0: Any): Boolean

Test two objects for equality. The expression x == that is equivalent to if (x eq null) that eq null else x.equals(that).

Test two objects for equality. The expression x == that is equivalent to if (x eq null) that eq null else x.equals(that).

Value parameters

that

the object to compare against this object for equality.

Attributes

Returns

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

final def asInstanceOf[X0]: X0

Cast the receiver object to be of type T0.

Cast the receiver object to be of type T0.

Note that the success of a cast at runtime is modulo Scala's erasure semantics. Therefore the expression 1.asInstanceOf[String] will throw a ClassCastException at runtime, while the expression List(1).asInstanceOf[List[String]] will not. In the latter example, because the type argument is erased as part of compilation it is not possible to check whether the contents of the list are of the requested type.

Attributes

Returns

the receiver object.

Throws
ClassCastException

if the receiver object is not an instance of the erasure of type T0.

def equals(x$0: Any): Boolean

Compares the receiver object (this) with the argument object (that) for equivalence.

Compares the receiver object (this) with the argument object (that) for equivalence.

Any implementation of this method should be an equivalence relation:

  • It is reflexive: for any instance x of type Any, x.equals(x) should return true.
  • It is symmetric: for any instances x and y of type Any, x.equals(y) should return true if and only if y.equals(x) returns true.
  • It is transitive: for any instances x, y, and z of type Any if x.equals(y) returns true and y.equals(z) returns true, then x.equals(z) should return true.

If you override this method, you should verify that your implementation remains an equivalence relation. Additionally, when overriding this method it is usually necessary to override hashCode to ensure that objects which are "equal" (o1.equals(o2) returns true) hash to the same scala.Int. (o1.hashCode.equals(o2.hashCode)).

Value parameters

that

the object to compare against this object for equality.

Attributes

Returns

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

final def getClass[X0 >: this.type](): Class[_ <: X0]

Returns the runtime class representation of the object.

Returns the runtime class representation of the object.

Attributes

Returns

a class object corresponding to the runtime type of the receiver.

def hashCode(): Int

Calculates a hash code value for the object.

Calculates a hash code value for the object.

The default hashing algorithm is platform dependent.

Note that it is allowed for two objects to have identical hash codes (o1.hashCode.equals(o2.hashCode)) yet not be equal (o1.equals(o2) returns false). A degenerate implementation could always return 0. However, it is required that if two objects are equal (o1.equals(o2) returns true) that they have identical hash codes (o1.hashCode.equals(o2.hashCode)). Therefore, when overriding this method, be sure to verify that the behavior is consistent with the equals method.

Attributes

Returns

the hash code value for this object.

final def isInstanceOf[X0]: Boolean

Test whether the dynamic type of the receiver object is T0.

Test whether the dynamic type of the receiver object is T0.

Note that the result of the test is modulo Scala's erasure semantics. Therefore the expression 1.isInstanceOf[String] will return false, while the expression List(1).isInstanceOf[List[String]] will return true. In the latter example, because the type argument is erased as part of compilation it is not possible to check whether the contents of the list are of the specified type.

Attributes

Returns

true if the receiver object is an instance of erasure of type T0; false otherwise.

def toString(): String

Returns a string representation of the object.

Returns a string representation of the object.

The default representation is platform dependent.

Attributes

Returns

a string representation of the object.