Movatterモバイル変換


[0]ホーム

URL:


Scala 3
3.7.4
LearnInstallPlaygroundFind A LibraryCommunityBlog
Scala 3
LearnInstallPlaygroundFind A LibraryCommunityBlog
DocsAPI
Generated with
Copyright (c) 2002-2025, LAMP/EPFL
Copyright (c) 2002-2025, LAMP/EPFL
Scala 3/scala

scala

packagescala

Core Scala types. They are always available without an explicit import.

Attributes

Members list

Packages

packagescala.caps

This package object contains primitives for concurrent and parallel programming.

This package object contains primitives for concurrent and parallel programming.

Guide

A more detailed guide to Futures and Promises, including discussion and examples can be found athttps://docs.scala-lang.org/overviews/core/futures.html.

Common Imports

When working with Futures, you will often find that importing the whole concurrent package is convenient:

import scala.concurrent._

When using things likeFutures, it is often required to have an implicitExecutionContext in scope. The general advice for these implicits are as follows.

If the code in question is a class or method definition, and noExecutionContext is available, request one from the caller by adding an implicit parameter list:

def myMethod(myParam: MyType)(implicit ec: ExecutionContext) = …//Orclass MyClass(myParam: MyType)(implicit ec: ExecutionContext) { … }

This allows the caller of the method, or creator of the instance of the class, to decide whichExecutionContext should be used.

For typical REPL usage and experimentation, importing the globalExecutionContext is often desired.

import scala.concurrent.ExcutionContext.Implicits.global

Specifying Durations

Operations often require a duration to be specified. A duration DSL is available to make defining these easier:

import scala.concurrent.duration._val d: Duration = 10.seconds

Using Futures For Non-blocking Computation

Basic use of futures is easy with the factory method on Future, which executes a provided function asynchronously, handing you back a future result of that function without blocking the current thread. In order to create the Future you will need either an implicit or explicit ExecutionContext to be provided:

import scala.concurrent._import ExecutionContext.Implicits.global  // implicit execution contextval firstZebra: Future[Int] = Future { val words = Files.readAllLines("/etc/dictionaries-common/words").asScala words.indexOfSlice("zebra")}

Avoid Blocking

Although blocking is possible in order to await results (with a mandatory timeout duration):

import scala.concurrent.duration._Await.result(firstZebra, 10.seconds)

and although this is sometimes necessary to do, in particular for testing purposes, blocking in general is discouraged when working with Futures and concurrency in order to avoid potential deadlocks and improve performance. Instead, use callbacks or combinators to remain in the future domain:

val animalRange: Future[Int] = for { aardvark <- firstAardvark zebra <- firstZebra} yield zebra - aardvarkanimalRange.onSuccess { case x if x > 500000 => println("It's a long way from Aardvark to Zebra")}

Attributes

packagescala.io
packagescala.jdk

The jdk package contains utilities to interact with JDK classes.

The jdk package contains utilities to interact with JDK classes.

This packages offers a number of converters, that are able to wrap or copy types from the scala library to equivalent types in the JDK class library and vice versa:

-CollectionConverters, converting collections likescala.collection.Seq,scala.collection.Map,scala.collection.Set,scala.collection.mutable.Buffer,scala.collection.Iterator andscala.collection.Iterable to their JDK counterparts -OptionConverters, converting betweenOption andjava.util.Optional and primitive variations -StreamConverters, to create JDK Streams from scala collections -DurationConverters, for conversions between scalascala.concurrent.duration.FiniteDuration andjava.time.Duration -FunctionConverters, from scala Functions to javajava.util.function.Function,java.util.function.UnaryOperator,java.util.function.Consumer andjava.util.function.Predicate, as well as primitive variations and Bi-variations.

By convention, converters that wrap an object to provide a different interface to the same underlying data structure use .asScala and .asJava extension methods, whereas converters that copy the underlying data structure use .toScala and .toJava.

In thejavaapi package, the same converters can be found with a java-friendly interface that don't rely on implicit enrichments.

Additionally, this package offersAccumulators, capable of efficiently traversing JDK Streams.

Attributes

packagescala.math

The package objectscala.math contains methods for performing basic numeric operations such as elementary exponential, logarithmic, root and trigonometric functions.

The package objectscala.math contains methods for performing basic numeric operations such as elementary exponential, logarithmic, root and trigonometric functions.

All methods forward tojava.lang.Math unless otherwise noted.

Attributes

See also
packagescala.ref
packagescala.sys

The package objectscala.sys contains methods for reading and altering core aspects of the virtual machine as well as the world outside of it.

The package objectscala.sys contains methods for reading and altering core aspects of the virtual machine as well as the world outside of it.

Attributes

packagescala.util

Type members

Classlikes

object#::

Attributes

Source
package.scala
Supertypes
classObject
traitMatchable
classAny
Self type
#::.type
sealed abstractclass*:[+H,+T <:Tuple] extendsNonEmptyTuple

Attributes

Companion
object
Source
Tuple.scala
Supertypes
traitTuple
traitProduct
traitEquals
classObject
traitMatchable
classAny
Show all
object*:

Attributes

Companion
class
Source
Tuple.scala
Supertypes
classObject
traitMatchable
classAny
Self type
*:.type
sealed abstractclass<:<[-From,+To] extendsFrom=>To,Serializable

An instance ofA <:< B witnesses thatA is a subtype ofB.

An instance ofA <:< B witnesses thatA is a subtype ofB. Requiring an implicit argument of the typeA <:< B encodes the generalized constraintA <: B.

To constrain any abstract typeT that's in scope in a method's argument list (not just the method's own type parameters) simply add an implicit argument of typeT <:< U, whereU is the required upper bound; or for lower-bounds, use:L <:< T, whereL is the required lower bound.

In case of any confusion over which method goes in what direction, all the "Co" methods (includingapply) go from left to right in the type ("with" the type), and all the "Contra" methods go from right to left ("against" the type). E.g.,apply turns aFrom into aTo, andsubstituteContra replaces theTos in a type withFroms.

In part contributed by Jason Zaugg.

Type parameters

From

a type which is proved a subtype ofTo

To

a type which is proved a supertype ofFrom

Attributes

See also

=:= for expressing equality constraints

Example

scala.Option#flatten

sealed trait Option[+A] {  // def flatten[B, A <: Option[B]]: Option[B] = ...  // won't work, since the A in flatten shadows the class-scoped A.  def flatten[B](implicit ev: A <:< Option[B]): Option[B]    = if(isEmpty) None else ev(get)  // Because (A <:< Option[B]) <: (A => Option[B]), ev can be called to turn the  // A from get into an Option[B], and because ev is implicit, that call can be  // left out and inserted automatically.}
Companion
object
Source
typeConstraints.scala
Supertypes
traitFrom=>To
classObject
traitMatchable
classAny
Known subtypes
classFrom=:=To
object<:<

Attributes

Companion
class
Source
typeConstraints.scala
Supertypes
classObject
traitMatchable
classAny
Self type
<:<.type
sealed abstractclass=:=[From,To] extendsFrom<:<To,Serializable

An instance ofA =:= B witnesses that the typesA andB are equal.

An instance ofA =:= B witnesses that the typesA andB are equal. It also acts as aA <:< B, but not aB <:< A (directly) due to restrictions on subclassing.

In case of any confusion over which method goes in what direction, all the "Co" methods (includingapply) go from left to right in the type ("with" the type), and all the "Contra" methods go from right to left ("against" the type). E.g.,apply turns aFrom into aTo, andsubstituteContra replaces theTos in a type withFroms.

Type parameters

From

a type which is proved equal toTo

To

a type which is proved equal toFrom

Attributes

See also

<:< for expressing subtyping constraints

Example

An in-place variant ofscala.collection.mutable.ArrayBuffer#transpose

implicit class BufOps[A](private val buf: ArrayBuffer[A]) extends AnyVal {  def inPlaceTranspose[E]()(implicit ev: A =:= ArrayBuffer[E]) = ???  // Because ArrayBuffer is invariant, we can't make do with just a A <:< ArrayBuffer[E]  // Getting buffers *out* from buf would work, but adding them back *in* wouldn't.}
Source
typeConstraints.scala
Supertypes
classFrom<:<To
traitFrom=>To
classObject
traitMatchable
classAny
Show all
abstract openclassAny

ClassAny is the root of the Scala class hierarchy.

ClassAny 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 extendAny usinguniversal traits. Auniversal trait is a trait that extendsAny, only hasdefs as members, and does no initialization.

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

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

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

Attributes

final abstractclassAnyKind

The super-type of all types.

classAnyRef

ClassAnyRef is the root class of allreference types.

ClassAnyRef is the root class of allreference types. All types except the value types descend from this class.

Attributes

Known subtypes
trait ()=>R
traitReference[T]
classSoftReference[T]
classWeakReference[T]
traitT1=>R
traitSetOps[A,CC,C]
traitSetOps[A,CC,C]
traitSet[A]
classAbstractSet[A]
classBitSet
classBitSet1
classBitSet2
classBitSetN
classHashSet[A]
classListSet[A]
classSet1[A]
classSet2[A]
classSet3[A]
classSet4[A]
classTreeSet[A]
traitSortedSet[A]
traitSortedSetOps[A,CC,C]
traitStrictOptimizedSetOps[A,CC,C]
traitSetOps[A,CC,C]
classHashSet[A]
classLinkedHashSet[A]
traitSet[A]
classAbstractSet[A]
classBitSet
classTreeSet[A]
traitSortedSet[A]
traitSortedSetOps[A,CC,C]
traitSet[A]
classAbstractSet[A]
traitSortedSet[A]
traitBitSet
traitSortedSetOps[A,CC,C]
traitBitSetOps[C]
traitSortedSetFactoryDefaults[A,CC,WithFilterCC]
traitStrictOptimizedSetOps[A,CC,C]
classFromJavaFunction[T,R]
classAbstractFunction1[T1,R]
classFrom<:<To
classFrom=:=To
classConversion[T,U]
traitPartialFunction[A,B]
traitMapOps[K,V,CC,C]
traitMapOps[K,V,CC,C]
traitMap[K,V]
classAbstractMap[K,V]
classHashMap[K,V]
classIntMap[T]
classListMap[K,V]
classLongMap[T]
classMap1[K,V]
classMap2[K,V]
classMap3[K,V]
classMap4[K,V]
classWithDefault[K,V]
classWithDefault[K,V]
classTreeMap[K,V]
classTreeSeqMap[K,V]
classVectorMap[K,V]
traitSeqMap[K,V]
traitSortedMap[K,V]
traitSortedMapOps[K,V,CC,C]
traitStrictOptimizedMapOps[K,V,CC,C]
traitMapOps[K,V,CC,C]
classTrieMap[K,V]
classAnyRefMap[K,V]
classHashMap[K,V]
classLinkedHashMap[K,V]
classListMap[K,V]
classLongMap[V]
traitMap[K,V]
traitMap[K,V]
classAbstractMap[K,V]
classWithDefault[K,V]
classWithDefault[K,V]
classOpenHashMap[Key,Value]
classTreeMap[K,V]
traitMultiMap[K,V]
traitSeqMap[K,V]
traitSortedMap[K,V]
traitSortedMapOps[K,V,CC,C]
traitMap[K,V]
classAbstractMap[K,V]
traitDefaultMap[K,V]
traitSeqMap[K,V]
traitSortedMap[K,V]
traitMapFactoryDefaults[K,V,CC,WithFilterCC]
classWeakHashMap[K,V]
traitMapView[K,V]
classAbstractMapView[K,V]
classFilter[K,V]
classFilterKeys[K,V]
classId[K,V]
classMapValues[K,V,W]
classTapEach[K,V,U]
traitSortedMapFactoryDefaults[K,V,CC,WithFilterCC,UnsortedCC]
traitSortedMapOps[K,V,CC,C]
traitStrictOptimizedMapOps[K,V,CC,C]
traitSeq[A]
traitSeq[A]
classAbstractSeq[A]
classArraySeq[A]
classofBoolean
classofByte
classofChar
classofDouble
classofFloat
classofInt
classofLong
classofRef[T]
classofShort
classofUnit
classLazyList[A]
classList[A]
class::[A]
objectNil
classNumericRange[T]
classExclusive[T]
classInclusive[T]
classQueue[A]
classRange
classExclusive
classInclusive
classStream[A]
classCons[A]
objectEmpty
classVector[A]
traitIndexedSeq[A]
traitLinearSeq[A]
traitSeq[A]
classAbstractSeq[A]
classArrayBuffer[A]
classArrayDeque[A]
classQueue[A]
classStack[A]
classListBuffer[A]
classArraySeq[T]
classofBoolean
classofByte
classofChar
classofDouble
classofFloat
classofInt
classofLong
classofRef[T]
classofShort
classofUnit
traitBuffer[A]
traitIndexedBuffer[A]
traitIndexedSeq[T]
classAccumulator[A,CC,C]
classAbstractSeq[A]
traitIndexedSeq[A]
traitLinearSeq[A]
trait (T1,T2,T3,T4,T5,T6,T7,T8,T9,T10)=>R
classAbstractFunction10[T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,R]
trait (T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11)=>R
classAbstractFunction11[T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,R]
trait (T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12)=>R
classAbstractFunction12[T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,R]
trait (T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13)=>R
classAbstractFunction13[T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,R]
trait (T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14)=>R
classAbstractFunction14[T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,R]
trait (T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15)=>R
classAbstractFunction15[T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,R]
trait (T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16)=>R
classAbstractFunction16[T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,R]
trait (T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17)=>R
classAbstractFunction17[T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,R]
trait (T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18)=>R
classAbstractFunction18[T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,R]
trait (T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19)=>R
classAbstractFunction19[T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,R]
trait (T1,T2)=>R
classFromJavaBiFunction[T,U,R]
classAbstractFunction2[T1,T2,R]
trait (T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20)=>R
classAbstractFunction20[T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,R]
trait (T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21)=>R
classAbstractFunction21[T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,R]
trait (T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22)=>R
classAbstractFunction22[T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,R]
trait (T1,T2,T3)=>R
classAbstractFunction3[T1,T2,T3,R]
trait (T1,T2,T3,T4)=>R
classAbstractFunction4[T1,T2,T3,T4,R]
trait (T1,T2,T3,T4,T5)=>R
classAbstractFunction5[T1,T2,T3,T4,T5,R]
trait (T1,T2,T3,T4,T5,T6)=>R
classAbstractFunction6[T1,T2,T3,T4,T5,T6,R]
trait (T1,T2,T3,T4,T5,T6,T7)=>R
classAbstractFunction7[T1,T2,T3,T4,T5,T6,T7,R]
trait (T1,T2,T3,T4,T5,T6,T7,T8)=>R
classAbstractFunction8[T1,T2,T3,T4,T5,T6,T7,T8,R]
trait (T1,T2,T3,T4,T5,T6,T7,T8,T9)=>R
classAbstractFunction9[T1,T2,T3,T4,T5,T6,T7,T8,T9,R]
Show all
abstract openclassAnyVal

AnyVal is the root class of allvalue types, which describe values not implemented as objects in the underlying host system.

AnyVal is the root class of allvalue types, which describe values not implemented as objects in the underlying host system. Value classes are specified in Scala Language Specification, section 12.2.

The standard implementation includes nineAnyVal subtypes:

scala.Double,scala.Float,scala.Long,scala.Int,scala.Char,scala.Short, andscala.Byte are thenumeric value types.

scala.Unit andscala.Boolean are thenon-numeric value types.

Other groupings:

Prior to Scala 2.10,AnyVal was a sealed trait. Beginning with Scala 2.10, however, it is possible to define a subclass ofAnyVal called auser-defined value class which is treated specially by the compiler. Properly-defined user value classes provide a way to improve performance on user-defined types by avoiding object allocation at runtime, and by replacing virtual method invocations with static method invocations.

User-defined value classes which avoid object allocation...

  • must have a singleval parameter that is the underlying runtime representation.

  • can definedefs, but novals,vars, or nestedtraitss,classes orobjects.

  • typically extend no other trait apart fromAnyVal.

  • cannot be used in type tests or pattern matching.

  • may not overrideequals orhashCode methods.

A minimal example:

class Wrapper(val underlying: Int) extends AnyVal {  def foo: Wrapper = new Wrapper(underlying * 19)}

It's important to note that user-defined value classes are limited, and in some circumstances, still must allocate a value class instance at runtime. These limitations and circumstances are explained in greater detail in theValue Classes and Universal Traits.

Attributes

Supertypes
traitMatchable
classAny
Known subtypes
classDeferrer[A]
classPartial[T,U]
classDeferrer[A]
classUnwrapOp
classArrayOps[A]
classSearchImpl[Repr,A]
classShape
classStringOps
classIntMult
classLongMult
classFutureOps[T]
classRichOption[A]
classRichOptional[A]
classRichByte
classRichChar
classRichFloat
classRichInt
classRichLong
classRichShort
classTuple2Zipped[El1,It1,El2,It2]
classOps[T1,T2]
classTuple3Zipped[El1,It1,El2,It2,El3,It3]
classOps[T1,T2,T3]
classChainingOps[A]
classBoolean
classByte
classChar
classDouble
classFloat
classUnliftOps[A,B]
classInt
classLong
classArrowAssoc[A]
classEnsuring[A]
classStringFormat[A]
classany2stringadd[A]
classShort
classUnit
classValueOf[T]
Show all
traitApp extendsDelayedInit

TheApp trait can be used to quickly turn objects into executable programs.

TheApp trait can be used to quickly turn objects into executable programs. Here is an example:

object Main extends App {  Console.println("Hello World: " + (args mkString ", "))}

No explicitmain method is needed. Instead, the whole class body becomes the “main method”.

args returns the current command line arguments as an array.

Caveats

It should be noted that this trait is implemented using theDelayedInit functionality, which means that fields of the object will not have been initialized before the main method has been executed.

Future versions of this trait will no longer extendDelayedInit.

In Scala 3, theDelayedInit feature was dropped.App exists only in a limited form that also does not support command line arguments and will be deprecated in the future.

@main methods are the recommended scheme to generate programs that can be invoked from the command line in Scala 3.

@main def runMyProgram(args: String*): Unit = {  // your program here}

If programs need to cross-build between Scala 2 and Scala 3, it is recommended to use an explicitmain method:

object Main {  def main(args: Array[String]): Unit = {    // your program here  }}

Attributes

Source
App.scala
Supertypes
classObject
traitMatchable
classAny
objectArray

Utility methods for operating on arrays.

Utility methods for operating on arrays. For example:

val a = Array(1, 2)val b = Array.ofDim[Int](2)val c = Array.concat(a, b)

where the array objectsa,b andc have respectively the valuesArray(1, 2),Array(0, 0) andArray(1, 2, 0, 0).

Attributes

Companion
class
Source
Array.scala
Supertypes
classObject
traitMatchable
classAny
Self type
Array.type
finalclassArray[T](_length:Int) extendsSerializable,Cloneable

Arrays are mutable, indexed collections of values.

Arrays are mutable, indexed collections of values.Array[T] is Scala's representation for Java'sT[].

val numbers = Array(1, 2, 3, 4)val first = numbers(0) // read the first elementnumbers(3) = 100 // replace the 4th array element with 100val biggerNumbers = numbers.map(_ * 2) // multiply all numbers by two

Arrays make use of two common pieces of Scala syntactic sugar, shown on lines 2 and 3 of the above example code. Line 2 is translated into a call toapply(Int), while line 3 is translated into a call toupdate(Int, T).

Two implicit conversions exist inscala.Predef that are frequently applied to arrays: a conversion toscala.collection.ArrayOps (shown on line 4 of the example above) and a conversion toscala.collection.mutable.ArraySeq (a subtype ofscala.collection.Seq). Both types make available many of the standard operations found in the Scala collections API. The conversion toArrayOps is temporary, as all operations defined onArrayOps return anArray, while the conversion toArraySeq is permanent as all operations return aArraySeq.

The conversion toArrayOps takes priority over the conversion toArraySeq. For instance, consider the following code:

val arr = Array(1, 2, 3)val arrReversed = arr.reverseval seqReversed : collection.Seq[Int] = arr.reverse

ValuearrReversed will be of typeArray[Int], with an implicit conversion toArrayOps occurring to perform thereverse operation. The value ofseqReversed, on the other hand, will be computed by converting toArraySeq first and invoking the variant ofreverse that returns anotherArraySeq.

Attributes

See also

Scala Language Specification, for in-depth information on the transformations the Scala compiler makes on Arrays (Sections 6.6 and 6.15 respectively.)

"Scala 2.8 Arrays" the Scala Improvement Document detailing arrays since Scala 2.8.

"The Scala 2.8 Collections' API" section onArray by Martin Odersky for more information.

Companion
object
Source
Array.scala
Supertypes
traitCloneable
classObject
traitMatchable
classAny
final abstractclassBoolean() extendsAnyVal

Boolean (equivalent to Java'sboolean primitive type) is a subtype ofscala.AnyVal.

Boolean (equivalent to Java'sboolean primitive type) is a subtype ofscala.AnyVal. Instances ofBoolean are not represented by an object in the underlying runtime system.

There is an implicit conversion fromscala.Boolean =>scala.runtime.RichBoolean which provides useful non-primitive operations.

Attributes

Companion
object
Source
Boolean.scala
Supertypes
classAnyVal
traitMatchable
classAny
objectBoolean

Attributes

Companion
class
Source
Boolean.scala
Supertypes
classObject
traitMatchable
classAny
Self type
Boolean.type
final abstractclassByte() extendsAnyVal

Byte, a 8-bit signed integer (equivalent to Java'sbyte primitive type) is a subtype ofscala.AnyVal.

Byte, a 8-bit signed integer (equivalent to Java'sbyte primitive type) is a subtype ofscala.AnyVal. Instances ofByte are not represented by an object in the underlying runtime system.

There is an implicit conversion fromscala.Byte =>scala.runtime.RichByte which provides useful non-primitive operations.

Attributes

Companion
object
Source
Byte.scala
Supertypes
classAnyVal
traitMatchable
classAny
objectByte

Attributes

Companion
class
Source
Byte.scala
Supertypes
classObject
traitMatchable
classAny
Self type
Byte.type
sealedtraitCanEqual[-L,-R]

A marker trait indicating that values of typeL can be compared to values of typeR.

A marker trait indicating that values of typeL can be compared to values of typeR.

Attributes

Companion
object
Source
CanEqual.scala
Supertypes
classObject
traitMatchable
classAny
Known subtypes
objectderived
objectCanEqual

Companion object containing a few universally knownCanEqual instances. CanEqual instances involving primitive types or the Null type are handled directly in the compiler (see Implicits.synthesizedCanEqual), so they are not included here.

Companion object containing a few universally knownCanEqual instances. CanEqual instances involving primitive types or the Null type are handled directly in the compiler (see Implicits.synthesizedCanEqual), so they are not included here.

Attributes

Companion
trait
Source
CanEqual.scala
Supertypes
traitSum
traitMirror
classObject
traitMatchable
classAny
Self type
final abstractclassChar() extendsAnyVal

Char, a 16-bit unsigned integer (equivalent to Java'schar primitive type) is a subtype ofscala.AnyVal.

Char, a 16-bit unsigned integer (equivalent to Java'schar primitive type) is a subtype ofscala.AnyVal. Instances ofChar are not represented by an object in the underlying runtime system.

There is an implicit conversion fromscala.Char =>scala.runtime.RichChar which provides useful non-primitive operations.

Attributes

Companion
object
Source
Char.scala
Supertypes
classAnyVal
traitMatchable
classAny
objectChar

Attributes

Companion
class
Source
Char.scala
Supertypes
classObject
traitMatchable
classAny
Self type
Char.type
objectConsole extendsAnsiColor

Implements functionality for printing Scala values on the terminal.

Implements functionality for printing Scala values on the terminal. For reading values useStdIn. Also defines constants for marking up text on ANSI terminals.

Console Output

Use the print methods to output text.

scala> Console.printf(  "Today the outside temperature is a balmy %.1f°C. %<.1f°C beats the previous record of %.1f°C.\n",  -137.0,  -135.05)Today the outside temperature is a balmy -137.0°C. -137.0°C beats the previous record of -135.1°C.

ANSI escape codes

Use the ANSI escape codes for colorizing console output either to STDOUT or STDERR.

import Console.{GREEN, RED, RESET, YELLOW_B, UNDERLINED}object PrimeTest {  def isPrime(): Unit = {    val candidate = io.StdIn.readInt().ensuring(_ > 1)    val prime = (2 to candidate - 1).forall(candidate % _ != 0)    if (prime)      Console.println(s"${RESET}${GREEN}yes${RESET}")    else      Console.err.println(s"${RESET}${YELLOW_B}${RED}${UNDERLINED}NO!${RESET}")  }  def main(args: Array[String]): Unit = isPrime()}

$ scala PrimeTest
1234567891
yes
$ scala PrimeTest
56474
NO!

IO redefinition

Use IO redefinition to temporarily swap in a different set of input and/or output streams. In this example the stream based method above is wrapped into a function.

import java.io.{ByteArrayOutputStream, StringReader}object FunctionalPrimeTest {  def isPrime(candidate: Int): Boolean = {    val input = new StringReader(s"$candidate\n")    val outCapture = new ByteArrayOutputStream    val errCapture = new ByteArrayOutputStream    Console.withIn(input) {      Console.withOut(outCapture) {        Console.withErr(errCapture) {          PrimeTest.isPrime()        }      }    }    if (outCapture.toByteArray.nonEmpty) // "yes"      true    else if (errCapture.toByteArray.nonEmpty) // "NO!"      false    else throw new IllegalArgumentException(candidate.toString)  }  def main(args: Array[String]): Unit = {    val primes = (2 to 50) filter (isPrime)    println(s"First primes: $primes")  }}

$ scala FunctionalPrimeTest
First primes: Vector(2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47)

Attributes

Source
Console.scala
Supertypes
traitAnsiColor
classObject
traitMatchable
classAny
Self type
Console.type
abstractclassConversion[-T,+U] extendsT=>U

A class for implicit values that can serve as implicit conversions. The implicit resolution algorithm will act as if there existed the additional implicit definition:

A class for implicit values that can serve as implicit conversions. The implicit resolution algorithm will act as if there existed the additional implicit definition:

def $implicitConversion[T, U](x: T)(c: Conversion[T, U]): U = c(x)

However, the presence of this definition would slow down implicit search since its outermost type matches any pair of types. Therefore, implicit search contains a special case inImplicits#discardForView which emulates the conversion in a more efficient way.

Note that this is a SAM class - function literals are automatically converted to theConversion values.

Also note that in bootstrapped dotty,Predef.<:< should inherit fromConversion. This would cut the number of special cases indiscardForView from two to one.

TheConversion class can also be used to convert explicitly, using theconvert extension method.

Attributes

Companion
object
Source
Conversion.scala
Supertypes
traitT=>U
classObject
traitMatchable
classAny

Attributes

Companion
class
Source
Conversion.scala
Supertypes
classObject
traitMatchable
classAny
Self type
final abstractclassDouble() extendsAnyVal

Double, a 64-bit IEEE-754 floating point number (equivalent to Java'sdouble primitive type) is a subtype ofscala.AnyVal.

Double, a 64-bit IEEE-754 floating point number (equivalent to Java'sdouble primitive type) is a subtype ofscala.AnyVal. Instances ofDouble are not represented by an object in the underlying runtime system.

There is an implicit conversion fromscala.Double =>scala.runtime.RichDouble which provides useful non-primitive operations.

Attributes

Companion
object
Source
Double.scala
Supertypes
classAnyVal
traitMatchable
classAny
objectDouble

Attributes

Companion
class
Source
Double.scala
Supertypes
classObject
traitMatchable
classAny
Self type
Double.type
finalclassDummyImplicit

A type for which there is always an implicit value.

A type for which there is always an implicit value.

Attributes

Companion
object
Source
DummyImplicit.scala
Supertypes
classObject
traitMatchable
classAny

Attributes

Companion
class
Source
DummyImplicit.scala
Supertypes
classObject
traitMatchable
classAny
Self type
traitDynamic

A marker trait that enables dynamic invocations.

A marker trait that enables dynamic invocations. Instancesx of this trait allow method invocationsx.meth(args) for arbitrary method namesmeth and argument listsargs as well as field accessesx.field for arbitrary field namesfield.

If a call is not natively supported byx (i.e. if type checking fails), it is rewritten according to the following rules:

foo.method("blah")      ~~> foo.applyDynamic("method")("blah")foo.method(x = "blah")  ~~> foo.applyDynamicNamed("method")(("x", "blah"))foo.method(x = 1, 2)    ~~> foo.applyDynamicNamed("method")(("x", 1), ("", 2))foo.field           ~~> foo.selectDynamic("field")foo.varia = 10      ~~> foo.updateDynamic("varia")(10)foo.arr(10) = 13    ~~> foo.selectDynamic("arr").update(10, 13)foo.arr(10)         ~~> foo.applyDynamic("arr")(10)

Defining direct or indirect subclasses of this trait is only possible if the language featuredynamics is enabled.

Attributes

Source
Dynamic.scala
Supertypes
classAny
caseobjectEmptyTuple extendsTuple

A tuple of 0 elements.

A tuple of 0 elements.

Attributes

Source
Tuple.scala
Supertypes
traitSingleton
traitProduct
traitMirror
traitTuple
traitProduct
traitEquals
classObject
traitMatchable
classAny
Show all
Self type
abstractclassEnumeration(initial:Int) extendsSerializable

Defines a finite set of values specific to the enumeration.

Defines a finite set of values specific to the enumeration. Typically these values enumerate all possible forms something can take and provide a lightweight alternative to case classes.

Each call to aValue method adds a new unique value to the enumeration. To be accessible, these values are usually defined asval members of the enumeration.

All values in an enumeration share a common, unique type defined as theValue type member of the enumeration (Value selected on the stable identifier path of the enumeration instance).

Values SHOULD NOT be added to an enumeration after its construction; doing so makes the enumeration thread-unsafe. If values are added to an enumeration from multiple threads (in a non-synchronized fashion) after construction, the behavior of the enumeration is undefined.

Value parameters

initial

The initial value from which to count the integers that identifies values at run-time.

Attributes

Example

// Define a new enumeration with a type alias and work with the full set of enumerated valuesobject WeekDay extends Enumeration { type WeekDay = Value val Mon, Tue, Wed, Thu, Fri, Sat, Sun = Value}import WeekDay._def isWorkingDay(d: WeekDay) = ! (d == Sat || d == Sun)WeekDay.values filter isWorkingDay foreach println// output:// Mon// Tue// Wed// Thu// Fri

// Example of adding attributes to an enumeration by extending the Enumeration.Val classobject Planet extends Enumeration { protected case class PlanetVal(mass: Double, radius: Double) extends super.Val {   def surfaceGravity: Double = Planet.G * mass / (radius * radius)   def surfaceWeight(otherMass: Double): Double = otherMass * surfaceGravity } import scala.language.implicitConversions implicit def valueToPlanetVal(x: Value): PlanetVal = x.asInstanceOf[PlanetVal] val G: Double = 6.67300E-11 val Mercury = PlanetVal(3.303e+23, 2.4397e6) val Venus   = PlanetVal(4.869e+24, 6.0518e6) val Earth   = PlanetVal(5.976e+24, 6.37814e6) val Mars    = PlanetVal(6.421e+23, 3.3972e6) val Jupiter = PlanetVal(1.9e+27, 7.1492e7) val Saturn  = PlanetVal(5.688e+26, 6.0268e7) val Uranus  = PlanetVal(8.686e+25, 2.5559e7) val Neptune = PlanetVal(1.024e+26, 2.4746e7)}println(Planet.values.filter(_.radius > 7.0e6))// output:// Planet.ValueSet(Jupiter, Saturn, Uranus, Neptune)
Source
Enumeration.scala
Supertypes
classObject
traitMatchable
classAny
Known subtypes
Self type
traitEquals

An interface containing operations for equality.

An interface containing operations for equality. The only method not already present in classAnyRef iscanEqual.

Attributes

Source
Equals.scala
Supertypes
classAny
Known subtypes
traitMap[K,V]
traitMap[K,V]
classAbstractMap[K,V]
classHashMap[K,V]
classIntMap[T]
classListMap[K,V]
classLongMap[T]
classMap1[K,V]
classMap2[K,V]
classMap3[K,V]
classMap4[K,V]
classWithDefault[K,V]
classWithDefault[K,V]
classTreeMap[K,V]
classTreeSeqMap[K,V]
classVectorMap[K,V]
traitSeqMap[K,V]
traitSortedMap[K,V]
traitMap[K,V]
traitMap[K,V]
classTrieMap[K,V]
classAbstractMap[K,V]
classAnyRefMap[K,V]
classHashMap[K,V]
classLinkedHashMap[K,V]
classListMap[K,V]
classLongMap[V]
classWithDefault[K,V]
classWithDefault[K,V]
classOpenHashMap[Key,Value]
classTreeMap[K,V]
traitMultiMap[K,V]
traitSeqMap[K,V]
traitSortedMap[K,V]
classAbstractMap[K,V]
traitDefaultMap[K,V]
traitSeqMap[K,V]
traitSortedMap[K,V]
traitSeq[A]
traitSeq[A]
classAbstractSeq[A]
classArraySeq[A]
classofBoolean
classofByte
classofChar
classofDouble
classofFloat
classofInt
classofLong
classofRef[T]
classofShort
classofUnit
classLazyList[A]
classList[A]
class::[A]
objectNil
classNumericRange[T]
classExclusive[T]
classInclusive[T]
classQueue[A]
classRange
classExclusive
classInclusive
classStream[A]
classCons[A]
objectEmpty
classVector[A]
traitIndexedSeq[A]
traitLinearSeq[A]
traitSeq[A]
classAbstractSeq[A]
classArrayBuffer[A]
classArrayDeque[A]
classQueue[A]
classStack[A]
classListBuffer[A]
classArraySeq[T]
classofBoolean
classofByte
classofChar
classofDouble
classofFloat
classofInt
classofLong
classofRef[T]
classofShort
classofUnit
traitBuffer[A]
traitIndexedBuffer[A]
traitIndexedSeq[T]
classAccumulator[A,CC,C]
classAbstractSeq[A]
traitIndexedSeq[A]
traitLinearSeq[A]
traitSet[A]
traitSet[A]
classAbstractSet[A]
classBitSet
classBitSet1
classBitSet2
classBitSetN
classHashSet[A]
classListSet[A]
classSet1[A]
classSet2[A]
classSet3[A]
classSet4[A]
classTreeSet[A]
traitSortedSet[A]
traitSet[A]
classAbstractSet[A]
classBitSet
classHashSet[A]
classLinkedHashSet[A]
classTreeSet[A]
traitSortedSet[A]
classAbstractSet[A]
traitSortedSet[A]
traitBitSet
traitClassTag[T]
traitManifest[T]
traitProduct
traitEnum
traitEnumValue
classTupleXXL
classEither[A,B]
classLeft[A,B]
classRight[A,B]
classTry[T]
classFailure[T]
classSuccess[T]
classOption[A]
objectNone
classSome[A]
traitProduct1[T1]
classTuple1[T1]
traitProduct10[T1,T2,T3,T4,T5,T6,T7,T8,T9,T10]
class (T1,T2,T3,T4,T5,T6,T7,T8,T9,T10)
traitProduct11[T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11]
class (T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11)
traitProduct12[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)
traitProduct13[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)
traitProduct14[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)
traitProduct15[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)
traitProduct16[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)
traitProduct17[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)
traitProduct18[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)
traitProduct19[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)
traitProduct2[T1,T2]
class (T1,T2)
traitProduct20[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)
traitProduct21[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)
traitProduct22[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)
traitProduct3[T1,T2,T3]
class (T1,T2,T3)
traitProduct4[T1,T2,T3,T4]
class (T1,T2,T3,T4)
traitProduct5[T1,T2,T3,T4,T5]
class (T1,T2,T3,T4,T5)
traitProduct6[T1,T2,T3,T4,T5,T6]
class (T1,T2,T3,T4,T5,T6)
traitProduct7[T1,T2,T3,T4,T5,T6,T7]
class (T1,T2,T3,T4,T5,T6,T7)
traitProduct8[T1,T2,T3,T4,T5,T6,T7,T8]
class (T1,T2,T3,T4,T5,T6,T7,T8)
traitProduct9[T1,T2,T3,T4,T5,T6,T7,T8,T9]
class (T1,T2,T3,T4,T5,T6,T7,T8,T9)
traitTuple
objectEmptyTuple
classH*:T
Show all
final abstractclassFloat() extendsAnyVal

Float, a 32-bit IEEE-754 floating point number (equivalent to Java'sfloat primitive type) is a subtype ofscala.AnyVal.

Float, a 32-bit IEEE-754 floating point number (equivalent to Java'sfloat primitive type) is a subtype ofscala.AnyVal. Instances ofFloat are not represented by an object in the underlying runtime system.

There is an implicit conversion fromscala.Float =>scala.runtime.RichFloat which provides useful non-primitive operations.

Attributes

Companion
object
Source
Float.scala
Supertypes
classAnyVal
traitMatchable
classAny
objectFloat

Attributes

Companion
class
Source
Float.scala
Supertypes
classObject
traitMatchable
classAny
Self type
Float.type
objectFunction

A module defining utility methods for higher-order functional programming.

A module defining utility methods for higher-order functional programming.

Attributes

Source
Function.scala
Supertypes
classObject
traitMatchable
classAny
Self type
traitFunction0[+R] extendsAnyRef

A function of 0 parameters.

A function of 0 parameters.

In the following example, the definition ofgreeting is shorthand, conceptually, for the anonymous class definitionanonfun0, although the implementation details of how the function value is constructed may differ:

object Main extends App {  val name = "world"  val greeting = () => s"hello, $name"  val anonfun0 = new Function0[String] {    def apply(): String = s"hello, $name"  }  assert(greeting() == anonfun0())}

Attributes

Source
Function0.scala
Supertypes
classObject
traitMatchable
classAny
Known subtypes
Self type
()=>R
objectFunction1

Attributes

Companion
trait
Source
Function1.scala
Supertypes
classObject
traitMatchable
classAny
Self type
traitFunction1[-T1,+R] extendsAnyRef

A function of 1 parameter.

A function of 1 parameter.

In the following example, the definition ofsucc is shorthand, conceptually, for the anonymous class definitionanonfun1, although the implementation details of how the function value is constructed may differ:

object Main extends App {  val succ = (x: Int) => x + 1  val anonfun1 = new Function1[Int, Int] {    def apply(x: Int): Int = x + 1  }  assert(succ(0) == anonfun1(0))}

Note that the difference betweenFunction1 andscala.PartialFunction is that the latter can specify inputs which it will not handle.

Attributes

Companion
object
Source
Function1.scala
Supertypes
classObject
traitMatchable
classAny
Known subtypes
traitSetOps[A,CC,C]
traitSetOps[A,CC,C]
traitSet[A]
classAbstractSet[A]
classBitSet
classBitSet1
classBitSet2
classBitSetN
classHashSet[A]
classListSet[A]
classSet1[A]
classSet2[A]
classSet3[A]
classSet4[A]
classTreeSet[A]
traitSortedSet[A]
traitSortedSetOps[A,CC,C]
traitStrictOptimizedSetOps[A,CC,C]
traitSetOps[A,CC,C]
classHashSet[A]
classLinkedHashSet[A]
traitSet[A]
classAbstractSet[A]
classBitSet
classTreeSet[A]
traitSortedSet[A]
traitSortedSetOps[A,CC,C]
traitSet[A]
classAbstractSet[A]
traitSortedSet[A]
traitBitSet
traitSortedSetOps[A,CC,C]
traitBitSetOps[C]
traitSortedSetFactoryDefaults[A,CC,WithFilterCC]
traitStrictOptimizedSetOps[A,CC,C]
classFromJavaFunction[T,R]
classAbstractFunction1[T1,R]
classFrom<:<To
classFrom=:=To
classConversion[T,U]
traitPartialFunction[A,B]
traitMapOps[K,V,CC,C]
traitMapOps[K,V,CC,C]
traitMap[K,V]
classAbstractMap[K,V]
classHashMap[K,V]
classIntMap[T]
classListMap[K,V]
classLongMap[T]
classMap1[K,V]
classMap2[K,V]
classMap3[K,V]
classMap4[K,V]
classWithDefault[K,V]
classWithDefault[K,V]
classTreeMap[K,V]
classTreeSeqMap[K,V]
classVectorMap[K,V]
traitSeqMap[K,V]
traitSortedMap[K,V]
traitSortedMapOps[K,V,CC,C]
traitStrictOptimizedMapOps[K,V,CC,C]
traitMapOps[K,V,CC,C]
classTrieMap[K,V]
classAnyRefMap[K,V]
classHashMap[K,V]
classLinkedHashMap[K,V]
classListMap[K,V]
classLongMap[V]
traitMap[K,V]
traitMap[K,V]
classAbstractMap[K,V]
classWithDefault[K,V]
classWithDefault[K,V]
classOpenHashMap[Key,Value]
classTreeMap[K,V]
traitMultiMap[K,V]
traitSeqMap[K,V]
traitSortedMap[K,V]
traitSortedMapOps[K,V,CC,C]
traitMap[K,V]
classAbstractMap[K,V]
traitDefaultMap[K,V]
traitSeqMap[K,V]
traitSortedMap[K,V]
traitMapFactoryDefaults[K,V,CC,WithFilterCC]
classWeakHashMap[K,V]
traitMapView[K,V]
classAbstractMapView[K,V]
classFilter[K,V]
classFilterKeys[K,V]
classId[K,V]
classMapValues[K,V,W]
classTapEach[K,V,U]
traitSortedMapFactoryDefaults[K,V,CC,WithFilterCC,UnsortedCC]
traitSortedMapOps[K,V,CC,C]
traitStrictOptimizedMapOps[K,V,CC,C]
traitSeq[A]
traitSeq[A]
classAbstractSeq[A]
classArraySeq[A]
classofBoolean
classofByte
classofChar
classofDouble
classofFloat
classofInt
classofLong
classofRef[T]
classofShort
classofUnit
classLazyList[A]
classList[A]
class::[A]
objectNil
classNumericRange[T]
classExclusive[T]
classInclusive[T]
classQueue[A]
classRange
classExclusive
classInclusive
classStream[A]
classCons[A]
objectEmpty
classVector[A]
traitIndexedSeq[A]
traitLinearSeq[A]
traitSeq[A]
classAbstractSeq[A]
classArrayBuffer[A]
classArrayDeque[A]
classQueue[A]
classStack[A]
classListBuffer[A]
classArraySeq[T]
classofBoolean
classofByte
classofChar
classofDouble
classofFloat
classofInt
classofLong
classofRef[T]
classofShort
classofUnit
traitBuffer[A]
traitIndexedBuffer[A]
traitIndexedSeq[T]
classAccumulator[A,CC,C]
classAbstractSeq[A]
traitIndexedSeq[A]
traitLinearSeq[A]
Show all
Self type
T1=>R
traitFunction10[-T1,-T2,-T3,-T4,-T5,-T6,-T7,-T8,-T9,-T10,+R] extendsAnyRef

A function of 10 parameters.

A function of 10 parameters.

Attributes

Source
Function10.scala
Supertypes
classObject
traitMatchable
classAny
Known subtypes
classAbstractFunction10[T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,R]
Self type
(T1,T2,T3,T4,T5,T6,T7,T8,T9,T10)=>R
traitFunction11[-T1,-T2,-T3,-T4,-T5,-T6,-T7,-T8,-T9,-T10,-T11,+R] extendsAnyRef

A function of 11 parameters.

A function of 11 parameters.

Attributes

Source
Function11.scala
Supertypes
classObject
traitMatchable
classAny
Known subtypes
classAbstractFunction11[T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,R]
Self type
(T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11)=>R
traitFunction12[-T1,-T2,-T3,-T4,-T5,-T6,-T7,-T8,-T9,-T10,-T11,-T12,+R] extendsAnyRef

A function of 12 parameters.

A function of 12 parameters.

Attributes

Source
Function12.scala
Supertypes
classObject
traitMatchable
classAny
Known subtypes
classAbstractFunction12[T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,R]
Self type
(T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12)=>R
traitFunction13[-T1,-T2,-T3,-T4,-T5,-T6,-T7,-T8,-T9,-T10,-T11,-T12,-T13,+R] extendsAnyRef

A function of 13 parameters.

A function of 13 parameters.

Attributes

Source
Function13.scala
Supertypes
classObject
traitMatchable
classAny
Known subtypes
classAbstractFunction13[T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,R]
Self type
(T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13)=>R
traitFunction14[-T1,-T2,-T3,-T4,-T5,-T6,-T7,-T8,-T9,-T10,-T11,-T12,-T13,-T14,+R] extendsAnyRef

A function of 14 parameters.

A function of 14 parameters.

Attributes

Source
Function14.scala
Supertypes
classObject
traitMatchable
classAny
Known subtypes
classAbstractFunction14[T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,R]
Self type
(T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14)=>R
traitFunction15[-T1,-T2,-T3,-T4,-T5,-T6,-T7,-T8,-T9,-T10,-T11,-T12,-T13,-T14,-T15,+R] extendsAnyRef

A function of 15 parameters.

A function of 15 parameters.

Attributes

Source
Function15.scala
Supertypes
classObject
traitMatchable
classAny
Known subtypes
classAbstractFunction15[T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,R]
Self type
(T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15)=>R
traitFunction16[-T1,-T2,-T3,-T4,-T5,-T6,-T7,-T8,-T9,-T10,-T11,-T12,-T13,-T14,-T15,-T16,+R] extendsAnyRef

A function of 16 parameters.

A function of 16 parameters.

Attributes

Source
Function16.scala
Supertypes
classObject
traitMatchable
classAny
Known subtypes
classAbstractFunction16[T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,R]
Self type
(T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16)=>R
traitFunction17[-T1,-T2,-T3,-T4,-T5,-T6,-T7,-T8,-T9,-T10,-T11,-T12,-T13,-T14,-T15,-T16,-T17,+R] extendsAnyRef

A function of 17 parameters.

A function of 17 parameters.

Attributes

Source
Function17.scala
Supertypes
classObject
traitMatchable
classAny
Known subtypes
classAbstractFunction17[T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,R]
Self type
(T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17)=>R
traitFunction18[-T1,-T2,-T3,-T4,-T5,-T6,-T7,-T8,-T9,-T10,-T11,-T12,-T13,-T14,-T15,-T16,-T17,-T18,+R] extendsAnyRef

A function of 18 parameters.

A function of 18 parameters.

Attributes

Source
Function18.scala
Supertypes
classObject
traitMatchable
classAny
Known subtypes
classAbstractFunction18[T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,R]
Self type
(T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18)=>R
traitFunction19[-T1,-T2,-T3,-T4,-T5,-T6,-T7,-T8,-T9,-T10,-T11,-T12,-T13,-T14,-T15,-T16,-T17,-T18,-T19,+R] extendsAnyRef

A function of 19 parameters.

A function of 19 parameters.

Attributes

Source
Function19.scala
Supertypes
classObject
traitMatchable
classAny
Known subtypes
classAbstractFunction19[T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,R]
Self type
(T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19)=>R
traitFunction2[-T1,-T2,+R] extendsAnyRef

A function of 2 parameters.

A function of 2 parameters.

In the following example, the definition ofmax is shorthand, conceptually, for the anonymous class definitionanonfun2, although the implementation details of how the function value is constructed may differ:

object Main extends App {  val max = (x: Int, y: Int) => if (x < y) y else x  val anonfun2 = new Function2[Int, Int, Int] {    def apply(x: Int, y: Int): Int = if (x < y) y else x  }  assert(max(0, 1) == anonfun2(0, 1))}

Attributes

Source
Function2.scala
Supertypes
classObject
traitMatchable
classAny
Known subtypes
classFromJavaBiFunction[T,U,R]
classAbstractFunction2[T1,T2,R]
Show all
Self type
(T1,T2)=>R
traitFunction20[-T1,-T2,-T3,-T4,-T5,-T6,-T7,-T8,-T9,-T10,-T11,-T12,-T13,-T14,-T15,-T16,-T17,-T18,-T19,-T20,+R] extendsAnyRef

A function of 20 parameters.

A function of 20 parameters.

Attributes

Source
Function20.scala
Supertypes
classObject
traitMatchable
classAny
Known subtypes
classAbstractFunction20[T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,R]
Self type
(T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20)=>R
traitFunction21[-T1,-T2,-T3,-T4,-T5,-T6,-T7,-T8,-T9,-T10,-T11,-T12,-T13,-T14,-T15,-T16,-T17,-T18,-T19,-T20,-T21,+R] extendsAnyRef

A function of 21 parameters.

A function of 21 parameters.

Attributes

Source
Function21.scala
Supertypes
classObject
traitMatchable
classAny
Known subtypes
classAbstractFunction21[T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,R]
Self type
(T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21)=>R
traitFunction22[-T1,-T2,-T3,-T4,-T5,-T6,-T7,-T8,-T9,-T10,-T11,-T12,-T13,-T14,-T15,-T16,-T17,-T18,-T19,-T20,-T21,-T22,+R] extendsAnyRef

A function of 22 parameters.

A function of 22 parameters.

Attributes

Source
Function22.scala
Supertypes
classObject
traitMatchable
classAny
Known subtypes
classAbstractFunction22[T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,R]
Self type
(T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22)=>R
traitFunction3[-T1,-T2,-T3,+R] extendsAnyRef

A function of 3 parameters.

A function of 3 parameters.

Attributes

Source
Function3.scala
Supertypes
classObject
traitMatchable
classAny
Known subtypes
classAbstractFunction3[T1,T2,T3,R]
Self type
(T1,T2,T3)=>R
traitFunction4[-T1,-T2,-T3,-T4,+R] extendsAnyRef

A function of 4 parameters.

A function of 4 parameters.

Attributes

Source
Function4.scala
Supertypes
classObject
traitMatchable
classAny
Known subtypes
classAbstractFunction4[T1,T2,T3,T4,R]
Self type
(T1,T2,T3,T4)=>R
traitFunction5[-T1,-T2,-T3,-T4,-T5,+R] extendsAnyRef

A function of 5 parameters.

A function of 5 parameters.

Attributes

Source
Function5.scala
Supertypes
classObject
traitMatchable
classAny
Known subtypes
classAbstractFunction5[T1,T2,T3,T4,T5,R]
Self type
(T1,T2,T3,T4,T5)=>R
traitFunction6[-T1,-T2,-T3,-T4,-T5,-T6,+R] extendsAnyRef

A function of 6 parameters.

A function of 6 parameters.

Attributes

Source
Function6.scala
Supertypes
classObject
traitMatchable
classAny
Known subtypes
classAbstractFunction6[T1,T2,T3,T4,T5,T6,R]
Self type
(T1,T2,T3,T4,T5,T6)=>R
traitFunction7[-T1,-T2,-T3,-T4,-T5,-T6,-T7,+R] extendsAnyRef

A function of 7 parameters.

A function of 7 parameters.

Attributes

Source
Function7.scala
Supertypes
classObject
traitMatchable
classAny
Known subtypes
classAbstractFunction7[T1,T2,T3,T4,T5,T6,T7,R]
Self type
(T1,T2,T3,T4,T5,T6,T7)=>R
traitFunction8[-T1,-T2,-T3,-T4,-T5,-T6,-T7,-T8,+R] extendsAnyRef

A function of 8 parameters.

A function of 8 parameters.

Attributes

Source
Function8.scala
Supertypes
classObject
traitMatchable
classAny
Known subtypes
classAbstractFunction8[T1,T2,T3,T4,T5,T6,T7,T8,R]
Self type
(T1,T2,T3,T4,T5,T6,T7,T8)=>R
traitFunction9[-T1,-T2,-T3,-T4,-T5,-T6,-T7,-T8,-T9,+R] extendsAnyRef

A function of 9 parameters.

A function of 9 parameters.

Attributes

Source
Function9.scala
Supertypes
classObject
traitMatchable
classAny
Known subtypes
classAbstractFunction9[T1,T2,T3,T4,T5,T6,T7,T8,T9,R]
Self type
(T1,T2,T3,T4,T5,T6,T7,T8,T9)=>R
objectIArray

An immutable array. AnIArray[T] has the same representation as anArray[T], but it cannot be updated. Unlike regular arrays, immutable arrays are covariant.

An immutable array. AnIArray[T] has the same representation as anArray[T], but it cannot be updated. Unlike regular arrays, immutable arrays are covariant.

Attributes

Source
IArray.scala
Supertypes
classObject
traitMatchable
classAny
Self type
IArray.type
final abstractclassInt() extendsAnyVal

Int, a 32-bit signed integer (equivalent to Java'sint primitive type) is a subtype ofscala.AnyVal.

Int, a 32-bit signed integer (equivalent to Java'sint primitive type) is a subtype ofscala.AnyVal. Instances ofInt are not represented by an object in the underlying runtime system.

There is an implicit conversion fromscala.Int =>scala.runtime.RichInt which provides useful non-primitive operations.

Attributes

Companion
object
Source
Int.scala
Supertypes
classAnyVal
traitMatchable
classAny
objectInt

Attributes

Companion
class
Source
Int.scala
Supertypes
classObject
traitMatchable
classAny
Self type
Int.type
final abstractclassLong() extendsAnyVal

Long, a 64-bit signed integer (equivalent to Java'slong primitive type) is a subtype ofscala.AnyVal.

Long, a 64-bit signed integer (equivalent to Java'slong primitive type) is a subtype ofscala.AnyVal. Instances ofLong are not represented by an object in the underlying runtime system.

There is an implicit conversion fromscala.Long =>scala.runtime.RichLong which provides useful non-primitive operations.

Attributes

Companion
object
Source
Long.scala
Supertypes
classAnyVal
traitMatchable
classAny
objectLong

Attributes

Companion
class
Source
Long.scala
Supertypes
classObject
traitMatchable
classAny
Self type
Long.type
finalclassMatchError(obj:Any) extendsRuntimeException

This class implements errors which are thrown whenever an object doesn't match any pattern of a pattern matching expression.

This class implements errors which are thrown whenever an object doesn't match any pattern of a pattern matching expression.

Attributes

Source
MatchError.scala
Supertypes
classException
classThrowable
classObject
traitMatchable
classAny
Show all
openclassMatchable

The base trait of types that can be safely pattern matched against.

The base trait of types that can be safely pattern matched against.

Seehttps://docs.scala-lang.org/scala3/reference/other-new-features/matchable.html.

Attributes

Supertypes
classAny

Attributes

Source
NamedTuple.scala
Supertypes
classObject
traitMatchable
classAny
Self type

Separate from NamedTuple object so that we can match on the opaque type NamedTuple.

Separate from NamedTuple object so that we can match on the opaque type NamedTuple.

Attributes

Source
NamedTuple.scala
Supertypes
classObject
traitMatchable
classAny
Self type
sealedtraitNonEmptyTuple extendsTuple

Tuple of arbitrary non-zero arity

Tuple of arbitrary non-zero arity

Attributes

Source
Tuple.scala
Supertypes
traitTuple
traitProduct
traitEquals
classObject
traitMatchable
classAny
Show all
Known subtypes
classH*:T
caseobjectNone extendsOption[Nothing]

This case object represents non-existent values.

This case object represents non-existent values.

Attributes

Source
Option.scala
Supertypes
traitProduct
traitEquals
classObject
traitMatchable
classAny
Show all
Self type
None.type
finalclassNotImplementedError(msg:String) extendsError

Throwing this exception can be a temporary replacement for a method body that remains to be implemented.

Throwing this exception can be a temporary replacement for a method body that remains to be implemented. For instance, the exception is thrown byPredef.???.

Attributes

Source
NotImplementedError.scala
Supertypes
classError
classThrowable
classObject
traitMatchable
classAny
Show all
final abstract openclassNothing

Nothing is - together withscala.Null - at the bottom of Scala's type hierarchy.

Nothing is - together withscala.Null - at the bottom of Scala's type hierarchy.

Nothing is a subtype of every other type (includingscala.Null); there existno instances of this type. Although typeNothing is uninhabited, it is nevertheless useful in several ways. For instance, the Scala library defines a valuescala.collection.immutable.Nil of typeList[Nothing]. Because lists are covariant in Scala, this makesscala.collection.immutable.Nil an instance ofList[T], for any element of typeT.

Another usage for Nothing is the return type for methods which never return normally. One example is method error inscala.sys, which always throws an exception.

Attributes

Supertypes
classAny
final abstract openclassNull

Null is - together withscala.Nothing - at the bottom of the Scala type hierarchy.

Null is - together withscala.Nothing - at the bottom of the Scala type hierarchy.

Null is the type of thenull literal. It is a subtype of every type except those of value classes. Value classes are subclasses ofAnyVal, which includes primitive types such asInt,Boolean, and user-defined value classes.

SinceNull is not a subtype of value types,null is not a member of any such type. For instance, it is not possible to assignnull to a variable of typescala.Int.

Attributes

Supertypes
classObject
traitMatchable
classAny
objectOption

Attributes

Companion
class
Source
Option.scala
Supertypes
classObject
traitMatchable
classAny
Self type
Option.type
sealed abstractclassOption[+A] extendsIterableOnce[A],Product,Serializable

Represents optional values.

Represents optional values. Instances ofOption are either an instance of $some or the object $none.

The most idiomatic way to use an $option instance is to treat it as a collection or monad and usemap,flatMap,filter, orforeach:

val name: Option[String] = request getParameter "name"val upper = name map { _.trim } filter { _.length != 0 } map { _.toUpperCase }println(upper getOrElse "")

Note that this is equivalent to

val upper = for {  name <- request getParameter "name"  trimmed <- Some(name.trim)  upper <- Some(trimmed.toUpperCase) if trimmed.length != 0} yield upperprintln(upper getOrElse "")

Because of how for comprehension works, if $none is returned fromrequest.getParameter, the entire expression results in $none

This allows for sophisticated chaining of $option values without having to check for the existence of a value.

These are useful methods that exist for both $some and $none. -isDefined — True if not empty -isEmpty — True if empty -nonEmpty — True if not empty -orElse — Evaluate and return alternate optional value if empty -getOrElse — Evaluate and return alternate value if empty -get — Return value, throw exception if empty -fold — Apply function on optional value, return default if empty -map — Apply a function on the optional value -flatMap — Same as map but function must return an optional value -foreach — Apply a procedure on option value -collect — Apply partial pattern match on optional value -filter — An optional value satisfies predicate -filterNot — An optional value doesn't satisfy predicate -exists — Apply predicate on optional value, or false if empty -forall — Apply predicate on optional value, or true if empty -contains — Checks if value equals optional value, or false if empty -zip — Combine two optional values to make a paired optional value -unzip — Split an optional pair to two optional values -unzip3 — Split an optional triple to three optional values -toList — Unary list of optional value, otherwise the empty list

A less-idiomatic way to use $option values is via pattern matching:

val nameMaybe = request getParameter "name"nameMaybe match {  case Some(name) =>    println(name.trim.toUppercase)  case None =>    println("No name value")}

Interacting with code that can occasionally return null can be safely wrapped in $option to become $none and $some otherwise.

val abc = new java.util.HashMap[Int, String]abc.put(1, "A")bMaybe = Option(abc.get(2))bMaybe match { case Some(b) =>   println(s"Found $b") case None =>   println("Not found")}

Attributes

Note

Many of the methods in here are duplicative with those in the Iterable hierarchy, but they are duplicated for a reason: the implicit conversion tends to leave one with an Iterable in situations where one could have retained an Option.

Companion
object
Source
Option.scala
Supertypes
traitProduct
traitEquals
traitIterableOnce[A]
classObject
traitMatchable
classAny
Show all
Known subtypes
objectNone
classSome[A]
Self type
traitPartialFunction[-A,+B] extendsA=>B

A partial function of typePartialFunction[A, B] is a unary function where the domain does not necessarily include all values of typeA.

A partial function of typePartialFunction[A, B] is a unary function where the domain does not necessarily include all values of typeA. The functionisDefinedAt allows to test dynamically if a value is in the domain of the function.

Even ifisDefinedAt returns true for ana: A, callingapply(a) may still throw an exception, so the following code is legal:

val f: PartialFunction[Int, Any] = { case x => x / 0 }   // ArithmeticException: / by zero

It is the responsibility of the caller to callisDefinedAt before callingapply, because ifisDefinedAt is false, it is not guaranteedapply will throw an exception to indicate an error condition. If an exception is not thrown, evaluation may result in an arbitrary value.

The usual way to respect this contract is to callapplyOrElse, which is expected to be more efficient than calling bothisDefinedAt andapply.

The main distinction betweenPartialFunction andscala.Function1 is that the user of aPartialFunction may choose to do something different with input that is declared to be outside its domain. For example:

val sample = 1 to 10def isEven(n: Int) = n % 2 == 0val eveningNews: PartialFunction[Int, String] = {  case x if isEven(x) => s"$x is even"}// The method collect is described as "filter + map"// because it uses a PartialFunction to select elements// to which the function is applied.val evenNumbers = sample.collect(eveningNews)val oddlyEnough: PartialFunction[Int, String] = {  case x if !isEven(x) => s"$x is odd"}// The method orElse allows chaining another PartialFunction// to handle input outside the declared domain.val numbers = sample.map(eveningNews orElse oddlyEnough)// same asval numbers = sample.map(n => eveningNews.applyOrElse(n, oddlyEnough))val half: PartialFunction[Int, Int] = {  case x if isEven(x) => x / 2}// Calculating the domain of a composition can be expensive.val oddByHalf = half.andThen(oddlyEnough)// Invokes `half.apply` on even elements!val oddBalls = sample.filter(oddByHalf.isDefinedAt)// Better than filter(oddByHalf.isDefinedAt).map(oddByHalf)val oddBalls = sample.collect(oddByHalf)// Providing "default" values.val oddsAndEnds = sample.map(n => oddByHalf.applyOrElse(n, (i: Int) => s"[$i]"))

Attributes

Note

OptionalFunctions,PartialFunctions and extractor objects can be converted to each other as shown in the following table.  

How to convert ...

to aPartialFunction

to an optionalFunction

to an extractor

from aPartialFunction

Predef.identity

lift

Predef.identity

from optionalFunction

Function1.UnliftOps#unlift orFunction.unlift

Predef.identity

Function1.UnliftOps#unlift

from an extractor

{ case extractor(x) => x }

extractor.unapply _

Predef.identity

 

Companion
object
Source
PartialFunction.scala
Supertypes
traitA=>B
classObject
traitMatchable
classAny
Known subtypes
traitMapOps[K,V,CC,C]
traitMapOps[K,V,CC,C]
traitMap[K,V]
classAbstractMap[K,V]
classHashMap[K,V]
classIntMap[T]
classListMap[K,V]
classLongMap[T]
classMap1[K,V]
classMap2[K,V]
classMap3[K,V]
classMap4[K,V]
classWithDefault[K,V]
classWithDefault[K,V]
classTreeMap[K,V]
classTreeSeqMap[K,V]
classVectorMap[K,V]
traitSeqMap[K,V]
traitSortedMap[K,V]
traitSortedMapOps[K,V,CC,C]
traitStrictOptimizedMapOps[K,V,CC,C]
traitMapOps[K,V,CC,C]
classTrieMap[K,V]
classAnyRefMap[K,V]
classHashMap[K,V]
classLinkedHashMap[K,V]
classListMap[K,V]
classLongMap[V]
traitMap[K,V]
traitMap[K,V]
classAbstractMap[K,V]
classWithDefault[K,V]
classWithDefault[K,V]
classOpenHashMap[Key,Value]
classTreeMap[K,V]
traitMultiMap[K,V]
traitSeqMap[K,V]
traitSortedMap[K,V]
traitSortedMapOps[K,V,CC,C]
traitMap[K,V]
classAbstractMap[K,V]
traitDefaultMap[K,V]
traitSeqMap[K,V]
traitSortedMap[K,V]
traitMapFactoryDefaults[K,V,CC,WithFilterCC]
classWeakHashMap[K,V]
traitMapView[K,V]
classAbstractMapView[K,V]
classFilter[K,V]
classFilterKeys[K,V]
classId[K,V]
classMapValues[K,V,W]
classTapEach[K,V,U]
traitSortedMapFactoryDefaults[K,V,CC,WithFilterCC,UnsortedCC]
traitSortedMapOps[K,V,CC,C]
traitStrictOptimizedMapOps[K,V,CC,C]
traitSeq[A]
traitSeq[A]
classAbstractSeq[A]
classArraySeq[A]
classofBoolean
classofByte
classofChar
classofDouble
classofFloat
classofInt
classofLong
classofRef[T]
classofShort
classofUnit
classLazyList[A]
classList[A]
class::[A]
objectNil
classNumericRange[T]
classExclusive[T]
classInclusive[T]
classQueue[A]
classRange
classExclusive
classInclusive
classStream[A]
classCons[A]
objectEmpty
classVector[A]
traitIndexedSeq[A]
traitLinearSeq[A]
traitSeq[A]
classAbstractSeq[A]
classArrayBuffer[A]
classArrayDeque[A]
classQueue[A]
classStack[A]
classListBuffer[A]
classArraySeq[T]
classofBoolean
classofByte
classofChar
classofDouble
classofFloat
classofInt
classofLong
classofRef[T]
classofShort
classofUnit
traitBuffer[A]
traitIndexedBuffer[A]
traitIndexedSeq[T]
classAccumulator[A,CC,C]
classAbstractSeq[A]
traitIndexedSeq[A]
traitLinearSeq[A]
Show all
Self type

A few handy operations which leverage the extra bit of information available in partial functions.

A few handy operations which leverage the extra bit of information available in partial functions. Examples:

import PartialFunction._def strangeConditional(other: Any): Boolean = cond(other) {  case x: String if x == "abc" || x == "def"  => true  case x: Int => true}def onlyInt(v: Any): Option[Int] = condOpt(v) { case x: Int => x }

Attributes

Companion
trait
Source
PartialFunction.scala
Supertypes
classObject
traitMatchable
classAny
Self type

Marker trait for polymorphic function types.

Marker trait for polymorphic function types.

This trait can only be refined with a polymorphic method, as long as that method is calledapply, e.g.: PolyFunction { def apply[T_1, ..., T_M](x_1: P_1, ..., x_N: P_N): R } Exactly one term argument list is expected. The term argument list may be contextual.

This type will be erased to FunctionN or FunctionXXL.

Attributes

Source
PolyFunction.scala
Supertypes
classObject
traitMatchable
classAny
objectPredef

ThePredef object provides definitions that are accessible in all Scala compilation units without explicit qualification.

ThePredef object provides definitions that are accessible in all Scala compilation units without explicit qualification.

Commonly Used Types

Predef provides type aliases for types which are commonly used, such as the immutable collection typesscala.collection.immutable.Map andscala.collection.immutable.Set.

Console Output

For basic console output,Predef provides convenience methodsprint andprintln, which are aliases of the methods in the objectscala.Console.

Assertions

A set ofassert functions are provided for use as a way to document and dynamically check invariants in code. Invocations ofassert can be elided at compile time by providing the command line option-Xdisable-assertions, which raises-Xelide-below aboveelidable.ASSERTION, to thescalac command.

Variants ofassert intended for use with static analysis tools are also provided:assume,require andensuring.require andensuring are intended for use as a means of design-by-contract style specification of pre- and post-conditions on functions, with the intention that these specifications could be consumed by a static analysis tool. For instance,

def addNaturals(nats: List[Int]): Int = {  require(nats forall (_ >= 0), "List contains negative numbers")  nats.foldLeft(0)(_ + _)} ensuring(_ >= 0)

The declaration ofaddNaturals states that the list of integers passed should only contain natural numbers (i.e. non-negative), and that the result returned will also be natural.require is distinct fromassert in that if the condition fails, then the caller of the function is to blame rather than a logical error having been made withinaddNaturals itself.ensuring is a form ofassert that declares the guarantee the function is providing with regards to its return value.

Implicit Conversions

A number of commonly applied implicit conversions are also defined here, and in the parent typescala.LowPriorityImplicits. Implicit conversions are provided for the "widening" of numeric values, for instance, converting a Short value to a Long value as required, and to add additional higher-order functions to Array values. These are described in more detail in the documentation ofscala.Array.

Attributes

Source
Predef.scala
Supertypes
classObject
traitMatchable
classAny
Self type
Predef.type
traitProduct extendsEquals

Base trait for all products, which in the standard library include at leastscala.Product1 throughscala.Product22 and therefore also their subclassesscala.Tuple1 throughscala.Tuple22.

Base trait for all products, which in the standard library include at leastscala.Product1 throughscala.Product22 and therefore also their subclassesscala.Tuple1 throughscala.Tuple22. In addition, all case classes implementProduct with synthetically generated methods.

Attributes

Source
Product.scala
Supertypes
traitEquals
classAny
Known subtypes
traitEnum
traitEnumValue
classTupleXXL
classEither[A,B]
classLeft[A,B]
classRight[A,B]
classTry[T]
classFailure[T]
classSuccess[T]
classOption[A]
objectNone
classSome[A]
traitProduct1[T1]
classTuple1[T1]
traitProduct10[T1,T2,T3,T4,T5,T6,T7,T8,T9,T10]
class (T1,T2,T3,T4,T5,T6,T7,T8,T9,T10)
traitProduct11[T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11]
class (T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11)
traitProduct12[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)
traitProduct13[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)
traitProduct14[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)
traitProduct15[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)
traitProduct16[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)
traitProduct17[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)
traitProduct18[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)
traitProduct19[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)
traitProduct2[T1,T2]
class (T1,T2)
traitProduct20[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)
traitProduct21[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)
traitProduct22[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)
traitProduct3[T1,T2,T3]
class (T1,T2,T3)
traitProduct4[T1,T2,T3,T4]
class (T1,T2,T3,T4)
traitProduct5[T1,T2,T3,T4,T5]
class (T1,T2,T3,T4,T5)
traitProduct6[T1,T2,T3,T4,T5,T6]
class (T1,T2,T3,T4,T5,T6)
traitProduct7[T1,T2,T3,T4,T5,T6,T7]
class (T1,T2,T3,T4,T5,T6,T7)
traitProduct8[T1,T2,T3,T4,T5,T6,T7,T8]
class (T1,T2,T3,T4,T5,T6,T7,T8)
traitProduct9[T1,T2,T3,T4,T5,T6,T7,T8,T9]
class (T1,T2,T3,T4,T5,T6,T7,T8,T9)
traitTuple
objectEmptyTuple
classH*:T
Show all
objectProduct1

Attributes

Companion
trait
Source
Product1.scala
Supertypes
classObject
traitMatchable
classAny
Self type
traitProduct1[+T1] extendsProduct

Product1 is a Cartesian product of 1 component.

Product1 is a Cartesian product of 1 component.

Attributes

Companion
object
Source
Product1.scala
Supertypes
traitProduct
traitEquals
classAny
Known subtypes
classTuple1[T1]
objectProduct10

Attributes

Companion
trait
Source
Product10.scala
Supertypes
classObject
traitMatchable
classAny
Self type
traitProduct10[+T1,+T2,+T3,+T4,+T5,+T6,+T7,+T8,+T9,+T10] extendsProduct

Product10 is a Cartesian product of 10 components.

Product10 is a Cartesian product of 10 components.

Attributes

Companion
object
Source
Product10.scala
Supertypes
traitProduct
traitEquals
classAny
Known subtypes
class (T1,T2,T3,T4,T5,T6,T7,T8,T9,T10)
objectProduct11

Attributes

Companion
trait
Source
Product11.scala
Supertypes
classObject
traitMatchable
classAny
Self type
traitProduct11[+T1,+T2,+T3,+T4,+T5,+T6,+T7,+T8,+T9,+T10,+T11] extendsProduct

Product11 is a Cartesian product of 11 components.

Product11 is a Cartesian product of 11 components.

Attributes

Companion
object
Source
Product11.scala
Supertypes
traitProduct
traitEquals
classAny
Known subtypes
class (T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11)
objectProduct12

Attributes

Companion
trait
Source
Product12.scala
Supertypes
classObject
traitMatchable
classAny
Self type
traitProduct12[+T1,+T2,+T3,+T4,+T5,+T6,+T7,+T8,+T9,+T10,+T11,+T12] extendsProduct

Product12 is a Cartesian product of 12 components.

Product12 is a Cartesian product of 12 components.

Attributes

Companion
object
Source
Product12.scala
Supertypes
traitProduct
traitEquals
classAny
Known subtypes
class (T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12)
objectProduct13

Attributes

Companion
trait
Source
Product13.scala
Supertypes
classObject
traitMatchable
classAny
Self type
traitProduct13[+T1,+T2,+T3,+T4,+T5,+T6,+T7,+T8,+T9,+T10,+T11,+T12,+T13] extendsProduct

Product13 is a Cartesian product of 13 components.

Product13 is a Cartesian product of 13 components.

Attributes

Companion
object
Source
Product13.scala
Supertypes
traitProduct
traitEquals
classAny
Known subtypes
class (T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13)
objectProduct14

Attributes

Companion
trait
Source
Product14.scala
Supertypes
classObject
traitMatchable
classAny
Self type
traitProduct14[+T1,+T2,+T3,+T4,+T5,+T6,+T7,+T8,+T9,+T10,+T11,+T12,+T13,+T14] extendsProduct

Product14 is a Cartesian product of 14 components.

Product14 is a Cartesian product of 14 components.

Attributes

Companion
object
Source
Product14.scala
Supertypes
traitProduct
traitEquals
classAny
Known subtypes
class (T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14)
objectProduct15

Attributes

Companion
trait
Source
Product15.scala
Supertypes
classObject
traitMatchable
classAny
Self type
traitProduct15[+T1,+T2,+T3,+T4,+T5,+T6,+T7,+T8,+T9,+T10,+T11,+T12,+T13,+T14,+T15] extendsProduct

Product15 is a Cartesian product of 15 components.

Product15 is a Cartesian product of 15 components.

Attributes

Companion
object
Source
Product15.scala
Supertypes
traitProduct
traitEquals
classAny
Known subtypes
class (T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15)
objectProduct16

Attributes

Companion
trait
Source
Product16.scala
Supertypes
classObject
traitMatchable
classAny
Self type
traitProduct16[+T1,+T2,+T3,+T4,+T5,+T6,+T7,+T8,+T9,+T10,+T11,+T12,+T13,+T14,+T15,+T16] extendsProduct

Product16 is a Cartesian product of 16 components.

Product16 is a Cartesian product of 16 components.

Attributes

Companion
object
Source
Product16.scala
Supertypes
traitProduct
traitEquals
classAny
Known subtypes
class (T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16)
objectProduct17

Attributes

Companion
trait
Source
Product17.scala
Supertypes
classObject
traitMatchable
classAny
Self type
traitProduct17[+T1,+T2,+T3,+T4,+T5,+T6,+T7,+T8,+T9,+T10,+T11,+T12,+T13,+T14,+T15,+T16,+T17] extendsProduct

Product17 is a Cartesian product of 17 components.

Product17 is a Cartesian product of 17 components.

Attributes

Companion
object
Source
Product17.scala
Supertypes
traitProduct
traitEquals
classAny
Known subtypes
class (T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17)
objectProduct18

Attributes

Companion
trait
Source
Product18.scala
Supertypes
classObject
traitMatchable
classAny
Self type
traitProduct18[+T1,+T2,+T3,+T4,+T5,+T6,+T7,+T8,+T9,+T10,+T11,+T12,+T13,+T14,+T15,+T16,+T17,+T18] extendsProduct

Product18 is a Cartesian product of 18 components.

Product18 is a Cartesian product of 18 components.

Attributes

Companion
object
Source
Product18.scala
Supertypes
traitProduct
traitEquals
classAny
Known subtypes
class (T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18)
objectProduct19

Attributes

Companion
trait
Source
Product19.scala
Supertypes
classObject
traitMatchable
classAny
Self type
traitProduct19[+T1,+T2,+T3,+T4,+T5,+T6,+T7,+T8,+T9,+T10,+T11,+T12,+T13,+T14,+T15,+T16,+T17,+T18,+T19] extendsProduct

Product19 is a Cartesian product of 19 components.

Product19 is a Cartesian product of 19 components.

Attributes

Companion
object
Source
Product19.scala
Supertypes
traitProduct
traitEquals
classAny
Known subtypes
class (T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19)
objectProduct2

Attributes

Companion
trait
Source
Product2.scala
Supertypes
classObject
traitMatchable
classAny
Self type
traitProduct2[+T1,+T2] extendsProduct

Product2 is a Cartesian product of 2 components.

Product2 is a Cartesian product of 2 components.

Attributes

Companion
object
Source
Product2.scala
Supertypes
traitProduct
traitEquals
classAny
Known subtypes
class (T1,T2)
objectProduct20

Attributes

Companion
trait
Source
Product20.scala
Supertypes
classObject
traitMatchable
classAny
Self type
traitProduct20[+T1,+T2,+T3,+T4,+T5,+T6,+T7,+T8,+T9,+T10,+T11,+T12,+T13,+T14,+T15,+T16,+T17,+T18,+T19,+T20] extendsProduct

Product20 is a Cartesian product of 20 components.

Product20 is a Cartesian product of 20 components.

Attributes

Companion
object
Source
Product20.scala
Supertypes
traitProduct
traitEquals
classAny
Known subtypes
class (T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20)
objectProduct21

Attributes

Companion
trait
Source
Product21.scala
Supertypes
classObject
traitMatchable
classAny
Self type
traitProduct21[+T1,+T2,+T3,+T4,+T5,+T6,+T7,+T8,+T9,+T10,+T11,+T12,+T13,+T14,+T15,+T16,+T17,+T18,+T19,+T20,+T21] extendsProduct

Product21 is a Cartesian product of 21 components.

Product21 is a Cartesian product of 21 components.

Attributes

Companion
object
Source
Product21.scala
Supertypes
traitProduct
traitEquals
classAny
Known subtypes
class (T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21)
objectProduct22

Attributes

Companion
trait
Source
Product22.scala
Supertypes
classObject
traitMatchable
classAny
Self type
traitProduct22[+T1,+T2,+T3,+T4,+T5,+T6,+T7,+T8,+T9,+T10,+T11,+T12,+T13,+T14,+T15,+T16,+T17,+T18,+T19,+T20,+T21,+T22] extendsProduct

Product22 is a Cartesian product of 22 components.

Product22 is a Cartesian product of 22 components.

Attributes

Companion
object
Source
Product22.scala
Supertypes
traitProduct
traitEquals
classAny
Known subtypes
class (T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22)
objectProduct3

Attributes

Companion
trait
Source
Product3.scala
Supertypes
classObject
traitMatchable
classAny
Self type
traitProduct3[+T1,+T2,+T3] extendsProduct

Product3 is a Cartesian product of 3 components.

Product3 is a Cartesian product of 3 components.

Attributes

Companion
object
Source
Product3.scala
Supertypes
traitProduct
traitEquals
classAny
Known subtypes
class (T1,T2,T3)
objectProduct4

Attributes

Companion
trait
Source
Product4.scala
Supertypes
classObject
traitMatchable
classAny
Self type
traitProduct4[+T1,+T2,+T3,+T4] extendsProduct

Product4 is a Cartesian product of 4 components.

Product4 is a Cartesian product of 4 components.

Attributes

Companion
object
Source
Product4.scala
Supertypes
traitProduct
traitEquals
classAny
Known subtypes
class (T1,T2,T3,T4)
objectProduct5

Attributes

Companion
trait
Source
Product5.scala
Supertypes
classObject
traitMatchable
classAny
Self type
traitProduct5[+T1,+T2,+T3,+T4,+T5] extendsProduct

Product5 is a Cartesian product of 5 components.

Product5 is a Cartesian product of 5 components.

Attributes

Companion
object
Source
Product5.scala
Supertypes
traitProduct
traitEquals
classAny
Known subtypes
class (T1,T2,T3,T4,T5)
objectProduct6

Attributes

Companion
trait
Source
Product6.scala
Supertypes
classObject
traitMatchable
classAny
Self type
traitProduct6[+T1,+T2,+T3,+T4,+T5,+T6] extendsProduct

Product6 is a Cartesian product of 6 components.

Product6 is a Cartesian product of 6 components.

Attributes

Companion
object
Source
Product6.scala
Supertypes
traitProduct
traitEquals
classAny
Known subtypes
class (T1,T2,T3,T4,T5,T6)
objectProduct7

Attributes

Companion
trait
Source
Product7.scala
Supertypes
classObject
traitMatchable
classAny
Self type
traitProduct7[+T1,+T2,+T3,+T4,+T5,+T6,+T7] extendsProduct

Product7 is a Cartesian product of 7 components.

Product7 is a Cartesian product of 7 components.

Attributes

Companion
object
Source
Product7.scala
Supertypes
traitProduct
traitEquals
classAny
Known subtypes
class (T1,T2,T3,T4,T5,T6,T7)
objectProduct8

Attributes

Companion
trait
Source
Product8.scala
Supertypes
classObject
traitMatchable
classAny
Self type
traitProduct8[+T1,+T2,+T3,+T4,+T5,+T6,+T7,+T8] extendsProduct

Product8 is a Cartesian product of 8 components.

Product8 is a Cartesian product of 8 components.

Attributes

Companion
object
Source
Product8.scala
Supertypes
traitProduct
traitEquals
classAny
Known subtypes
class (T1,T2,T3,T4,T5,T6,T7,T8)
objectProduct9

Attributes

Companion
trait
Source
Product9.scala
Supertypes
classObject
traitMatchable
classAny
Self type
traitProduct9[+T1,+T2,+T3,+T4,+T5,+T6,+T7,+T8,+T9] extendsProduct

Product9 is a Cartesian product of 9 components.

Product9 is a Cartesian product of 9 components.

Attributes

Companion
object
Source
Product9.scala
Supertypes
traitProduct
traitEquals
classAny
Known subtypes
class (T1,T2,T3,T4,T5,T6,T7,T8,T9)

An exception that indicates an error during Scala reflection

An exception that indicates an error during Scala reflection

Attributes

Source
package.scala
Supertypes
traitProduct
traitEquals
classException
classThrowable
classObject
traitMatchable
classAny
Show all

A marker trait for objects that support structural selection viaselectDynamic andapplyDynamic

A marker trait for objects that support structural selection viaselectDynamic andapplyDynamic

Implementation classes should define, or make available as extension methods, the following two method signatures:

def selectDynamic(name: String): Anydef applyDynamic(name: String)(args: Any*): Any =

selectDynamic is invoked for simple selectionsv.m, whereasapplyDynamic is invoked for selections with argumentsv.m(...). If there's only one kind of selection, the method supporting the other may be omitted. TheapplyDynamic can also have a second parameter list ofjava.lang.Class arguments, i.e. it may alternatively have the signature

def applyDynamic(name: String, paramClasses: Class[_]*)(args: Any*): Any

In this case the call will synthesizeClass arguments for the erasure of all formal parameter types of the method in the structural type.

Attributes

Companion
object
Source
Selectable.scala
Supertypes
classAny
Known subtypes

Attributes

Companion
trait
Source
Selectable.scala
Supertypes
classObject
traitMatchable
classAny
Self type

Annotation for specifying theserialVersionUID field of a (serializable) class.

Annotation for specifying theserialVersionUID field of a (serializable) class.

On the JVM, a class with this annotation will receive aprivate,static, andfinal field calledserialVersionUID with the providedvalue, which the JVM's serialization mechanism uses to determine serialization compatibility between different versions of a class.

Attributes

See also
Source
SerialVersionUID.scala
Supertypes
classObject
traitMatchable
classAny
Show all
final abstractclassShort() extendsAnyVal

Short, a 16-bit signed integer (equivalent to Java'sshort primitive type) is a subtype ofscala.AnyVal.

Short, a 16-bit signed integer (equivalent to Java'sshort primitive type) is a subtype ofscala.AnyVal. Instances ofShort are not represented by an object in the underlying runtime system.

There is an implicit conversion fromscala.Short =>scala.runtime.RichShort which provides useful non-primitive operations.

Attributes

Companion
object
Source
Short.scala
Supertypes
classAnyVal
traitMatchable
classAny
objectShort

Attributes

Companion
class
Source
Short.scala
Supertypes
classObject
traitMatchable
classAny
Self type
Short.type
final openclassSingleton

Singleton is used by the compiler as a supertype for singleton types.

Singleton is used by the compiler as a supertype for singleton types. This includes literal types, as they are also singleton types.

scala> object A { val x = 42 }defined object Ascala> implicitly[A.type <:< Singleton]res12: A.type <:< Singleton = generalized constraintscala> implicitly[A.x.type <:< Singleton]res13: A.x.type <:< Singleton = generalized constraintscala> implicitly[42 <:< Singleton]res14: 42 <:< Singleton = generalized constraintscala> implicitly[Int <:< Singleton]^error: Cannot prove that Int <:< Singleton.

Singleton has a special meaning when it appears as an upper bound on a formal type parameter. Normally, type inference in Scala widens singleton types to the underlying non-singleton type. When a type parameter has an explicit upper bound ofSingleton, the compiler infers a singleton type.

scala> def check42[T](x: T)(implicit ev: T =:= 42): T = xcheck42: [T](x: T)(implicit ev: T =:= 42)Tscala> val x1 = check42(42)^error: Cannot prove that Int =:= 42.scala> def singleCheck42[T <: Singleton](x: T)(implicit ev: T =:= 42): T = xsingleCheck42: [T <: Singleton](x: T)(implicit ev: T =:= 42)Tscala> val x2 = singleCheck42(42)x2: Int = 42

See alsoSIP-23 about Literal-based Singleton Types.

Attributes

Supertypes
classAny
final caseclassSome[+A](value:A) extendsOption[A]

ClassSome[A] represents existing values of typeA.

ClassSome[A] represents existing values of typeA.

Attributes

Source
Option.scala
Supertypes
classOption[A]
traitProduct
traitEquals
traitIterableOnce[A]
classObject
traitMatchable
classAny
Show all

A common supertype for companions of specializable types.

A common supertype for companions of specializable types. Should not be extended in user code.

Attributes

Companion
object
Source
Specializable.scala
Supertypes
classObject
traitMatchable
classAny

Attributes

Companion
trait
Source
Specializable.scala
Supertypes
classObject
traitMatchable
classAny
Self type
caseclassStringContext(parts:String*)

This class provides the basic mechanism to do String Interpolation.

This class provides the basic mechanism to do String Interpolation. String Interpolation allows users to embed variable references directly in *processed* string literals. Here's an example:

val name = "James"println(s"Hello, $name")  // Hello, James

Any processed string literal is rewritten as an instantiation and method call against this class. For example:

s"Hello, $name"

is rewritten to be:

StringContext("Hello, ", "").s(name)

By default, this class provides theraw,s andf methods as available interpolators.

To provide your own string interpolator, create an implicit class which adds a method toStringContext. Here's an example:

implicit class JsonHelper(private val sc: StringContext) extends AnyVal {  def json(args: Any*): JSONObject = ...}val x: JSONObject = json"{ a: $a }"

Here theJsonHelper extension class implicitly adds thejson method toStringContext which can be used forjson string literals.

Value parameters

parts

The parts that make up the interpolated string, without the expressions that get inserted by interpolation.

Attributes

Companion
object
Source
StringContext.scala
Supertypes
traitProduct
traitEquals
classObject
traitMatchable
classAny
Show all

Attributes

Companion
class
Source
StringContext.scala
Supertypes
classObject
traitMatchable
classAny
Self type
finalclassSymbol extendsSerializable

This class provides a simple way to get unique objects for equal strings.

This class provides a simple way to get unique objects for equal strings. Since symbols are interned, they can be compared using reference equality.

Attributes

Companion
object
Source
Symbol.scala
Supertypes
classObject
traitMatchable
classAny
objectSymbol

Attributes

Companion
class
Source
Symbol.scala
Supertypes
classObject
traitMatchable
classAny
Self type
Symbol.type
sealedtraitTuple extendsProduct

Tuple of arbitrary arity

Tuple of arbitrary arity

Attributes

Companion
object
Source
Tuple.scala
Supertypes
traitProduct
traitEquals
classObject
traitMatchable
classAny
Known subtypes
objectEmptyTuple
classH*:T
objectTuple

Attributes

Companion
trait
Source
Tuple.scala
Supertypes
classObject
traitMatchable
classAny
Self type
Tuple.type
final caseclassTuple1[+T1](_1:T1) extendsProduct1[T1]

A tuple of 1 elements; the canonical representation of ascala.Product1.

A tuple of 1 elements; the canonical representation of ascala.Product1.

Value parameters

_1

Element 1 of this Tuple1

Attributes

Constructor

Create a new tuple with 1 elements.

Source
Tuple1.scala
Supertypes
traitProduct1[T1]
classT1*:EmptyTuple.type
traitTuple
traitProduct
traitEquals
classObject
traitMatchable
classAny
Show all
final caseclassTuple10[+T1,+T2,+T3,+T4,+T5,+T6,+T7,+T8,+T9,+T10](_1:T1,_2:T2,_3:T3,_4:T4,_5:T5,_6:T6,_7:T7,_8:T8,_9:T9,_10:T10) extendsProduct10[T1,T2,T3,T4,T5,T6,T7,T8,T9,T10]

A tuple of 10 elements; the canonical representation of ascala.Product10.

A tuple of 10 elements; the canonical representation of ascala.Product10.

Value parameters

_1

Element 1 of this Tuple10

_10

Element 10 of this Tuple10

_2

Element 2 of this Tuple10

_3

Element 3 of this Tuple10

_4

Element 4 of this Tuple10

_5

Element 5 of this Tuple10

_6

Element 6 of this Tuple10

_7

Element 7 of this Tuple10

_8

Element 8 of this Tuple10

_9

Element 9 of this Tuple10

Attributes

Constructor

Create a new tuple with 10 elements. Note that it is more idiomatic to create a Tuple10 via(t1, t2, t3, t4, t5, t6, t7, t8, t9, t10)

Source
Tuple10.scala
Supertypes
traitProduct10[T1,T2,T3,T4,T5,T6,T7,T8,T9,T10]
classT1*:T2*:T3*:T4*:T5*:T6*:T7*:T8*:T9*:T10*:EmptyTuple.type
traitTuple
traitProduct
traitEquals
classObject
traitMatchable
classAny
Show all
final caseclassTuple11[+T1,+T2,+T3,+T4,+T5,+T6,+T7,+T8,+T9,+T10,+T11](_1:T1,_2:T2,_3:T3,_4:T4,_5:T5,_6:T6,_7:T7,_8:T8,_9:T9,_10:T10,_11:T11) extendsProduct11[T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11]

A tuple of 11 elements; the canonical representation of ascala.Product11.

A tuple of 11 elements; the canonical representation of ascala.Product11.

Value parameters

_1

Element 1 of this Tuple11

_10

Element 10 of this Tuple11

_11

Element 11 of this Tuple11

_2

Element 2 of this Tuple11

_3

Element 3 of this Tuple11

_4

Element 4 of this Tuple11

_5

Element 5 of this Tuple11

_6

Element 6 of this Tuple11

_7

Element 7 of this Tuple11

_8

Element 8 of this Tuple11

_9

Element 9 of this Tuple11

Attributes

Constructor

Create a new tuple with 11 elements. Note that it is more idiomatic to create a Tuple11 via(t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11)

Source
Tuple11.scala
Supertypes
traitProduct11[T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11]
classT1*:T2*:T3*:T4*:T5*:T6*:T7*:T8*:T9*:T10*:T11*:EmptyTuple.type
traitTuple
traitProduct
traitEquals
classObject
traitMatchable
classAny
Show all
final caseclassTuple12[+T1,+T2,+T3,+T4,+T5,+T6,+T7,+T8,+T9,+T10,+T11,+T12](_1:T1,_2:T2,_3:T3,_4:T4,_5:T5,_6:T6,_7:T7,_8:T8,_9:T9,_10:T10,_11:T11,_12:T12) extendsProduct12[T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12]

A tuple of 12 elements; the canonical representation of ascala.Product12.

A tuple of 12 elements; the canonical representation of ascala.Product12.

Value parameters

_1

Element 1 of this Tuple12

_10

Element 10 of this Tuple12

_11

Element 11 of this Tuple12

_12

Element 12 of this Tuple12

_2

Element 2 of this Tuple12

_3

Element 3 of this Tuple12

_4

Element 4 of this Tuple12

_5

Element 5 of this Tuple12

_6

Element 6 of this Tuple12

_7

Element 7 of this Tuple12

_8

Element 8 of this Tuple12

_9

Element 9 of this Tuple12

Attributes

Constructor

Create a new tuple with 12 elements. Note that it is more idiomatic to create a Tuple12 via(t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12)

Source
Tuple12.scala
Supertypes
traitProduct12[T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12]
classT1*:T2*:T3*:T4*:T5*:T6*:T7*:T8*:T9*:T10*:T11*:T12*:EmptyTuple.type
traitTuple
traitProduct
traitEquals
classObject
traitMatchable
classAny
Show all
final caseclassTuple13[+T1,+T2,+T3,+T4,+T5,+T6,+T7,+T8,+T9,+T10,+T11,+T12,+T13](_1:T1,_2:T2,_3:T3,_4:T4,_5:T5,_6:T6,_7:T7,_8:T8,_9:T9,_10:T10,_11:T11,_12:T12,_13:T13) extendsProduct13[T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13]

A tuple of 13 elements; the canonical representation of ascala.Product13.

A tuple of 13 elements; the canonical representation of ascala.Product13.

Value parameters

_1

Element 1 of this Tuple13

_10

Element 10 of this Tuple13

_11

Element 11 of this Tuple13

_12

Element 12 of this Tuple13

_13

Element 13 of this Tuple13

_2

Element 2 of this Tuple13

_3

Element 3 of this Tuple13

_4

Element 4 of this Tuple13

_5

Element 5 of this Tuple13

_6

Element 6 of this Tuple13

_7

Element 7 of this Tuple13

_8

Element 8 of this Tuple13

_9

Element 9 of this Tuple13

Attributes

Constructor

Create a new tuple with 13 elements. Note that it is more idiomatic to create a Tuple13 via(t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13)

Source
Tuple13.scala
Supertypes
traitProduct13[T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13]
classT1*:T2*:T3*:T4*:T5*:T6*:T7*:T8*:T9*:T10*:T11*:T12*:T13*:EmptyTuple.type
traitTuple
traitProduct
traitEquals
classObject
traitMatchable
classAny
Show all
final caseclassTuple14[+T1,+T2,+T3,+T4,+T5,+T6,+T7,+T8,+T9,+T10,+T11,+T12,+T13,+T14](_1:T1,_2:T2,_3:T3,_4:T4,_5:T5,_6:T6,_7:T7,_8:T8,_9:T9,_10:T10,_11:T11,_12:T12,_13:T13,_14:T14) extendsProduct14[T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14]

A tuple of 14 elements; the canonical representation of ascala.Product14.

A tuple of 14 elements; the canonical representation of ascala.Product14.

Value parameters

_1

Element 1 of this Tuple14

_10

Element 10 of this Tuple14

_11

Element 11 of this Tuple14

_12

Element 12 of this Tuple14

_13

Element 13 of this Tuple14

_14

Element 14 of this Tuple14

_2

Element 2 of this Tuple14

_3

Element 3 of this Tuple14

_4

Element 4 of this Tuple14

_5

Element 5 of this Tuple14

_6

Element 6 of this Tuple14

_7

Element 7 of this Tuple14

_8

Element 8 of this Tuple14

_9

Element 9 of this Tuple14

Attributes

Constructor

Create a new tuple with 14 elements. Note that it is more idiomatic to create a Tuple14 via(t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14)

Source
Tuple14.scala
Supertypes
traitProduct14[T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14]
classT1*:T2*:T3*:T4*:T5*:T6*:T7*:T8*:T9*:T10*:T11*:T12*:T13*:T14*:EmptyTuple.type
traitTuple
traitProduct
traitEquals
classObject
traitMatchable
classAny
Show all
final caseclassTuple15[+T1,+T2,+T3,+T4,+T5,+T6,+T7,+T8,+T9,+T10,+T11,+T12,+T13,+T14,+T15](_1:T1,_2:T2,_3:T3,_4:T4,_5:T5,_6:T6,_7:T7,_8:T8,_9:T9,_10:T10,_11:T11,_12:T12,_13:T13,_14:T14,_15:T15) extendsProduct15[T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15]

A tuple of 15 elements; the canonical representation of ascala.Product15.

A tuple of 15 elements; the canonical representation of ascala.Product15.

Value parameters

_1

Element 1 of this Tuple15

_10

Element 10 of this Tuple15

_11

Element 11 of this Tuple15

_12

Element 12 of this Tuple15

_13

Element 13 of this Tuple15

_14

Element 14 of this Tuple15

_15

Element 15 of this Tuple15

_2

Element 2 of this Tuple15

_3

Element 3 of this Tuple15

_4

Element 4 of this Tuple15

_5

Element 5 of this Tuple15

_6

Element 6 of this Tuple15

_7

Element 7 of this Tuple15

_8

Element 8 of this Tuple15

_9

Element 9 of this Tuple15

Attributes

Constructor

Create a new tuple with 15 elements. Note that it is more idiomatic to create a Tuple15 via(t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15)

Source
Tuple15.scala
Supertypes
traitProduct15[T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15]
classT1*:T2*:T3*:T4*:T5*:T6*:T7*:T8*:T9*:T10*:T11*:T12*:T13*:T14*:T15*:EmptyTuple.type
traitTuple
traitProduct
traitEquals
classObject
traitMatchable
classAny
Show all
final caseclassTuple16[+T1,+T2,+T3,+T4,+T5,+T6,+T7,+T8,+T9,+T10,+T11,+T12,+T13,+T14,+T15,+T16](_1:T1,_2:T2,_3:T3,_4:T4,_5:T5,_6:T6,_7:T7,_8:T8,_9:T9,_10:T10,_11:T11,_12:T12,_13:T13,_14:T14,_15:T15,_16:T16) extendsProduct16[T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16]

A tuple of 16 elements; the canonical representation of ascala.Product16.

A tuple of 16 elements; the canonical representation of ascala.Product16.

Value parameters

_1

Element 1 of this Tuple16

_10

Element 10 of this Tuple16

_11

Element 11 of this Tuple16

_12

Element 12 of this Tuple16

_13

Element 13 of this Tuple16

_14

Element 14 of this Tuple16

_15

Element 15 of this Tuple16

_16

Element 16 of this Tuple16

_2

Element 2 of this Tuple16

_3

Element 3 of this Tuple16

_4

Element 4 of this Tuple16

_5

Element 5 of this Tuple16

_6

Element 6 of this Tuple16

_7

Element 7 of this Tuple16

_8

Element 8 of this Tuple16

_9

Element 9 of this Tuple16

Attributes

Constructor

Create a new tuple with 16 elements. Note that it is more idiomatic to create a Tuple16 via(t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15, t16)

Source
Tuple16.scala
Supertypes
traitProduct16[T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16]
classT1*:T2*:T3*:T4*:T5*:T6*:T7*:T8*:T9*:T10*:T11*:T12*:T13*:T14*:T15*:T16*:EmptyTuple.type
traitTuple
traitProduct
traitEquals
classObject
traitMatchable
classAny
Show all
final caseclassTuple17[+T1,+T2,+T3,+T4,+T5,+T6,+T7,+T8,+T9,+T10,+T11,+T12,+T13,+T14,+T15,+T16,+T17](_1:T1,_2:T2,_3:T3,_4:T4,_5:T5,_6:T6,_7:T7,_8:T8,_9:T9,_10:T10,_11:T11,_12:T12,_13:T13,_14:T14,_15:T15,_16:T16,_17:T17) extendsProduct17[T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17]

A tuple of 17 elements; the canonical representation of ascala.Product17.

A tuple of 17 elements; the canonical representation of ascala.Product17.

Value parameters

_1

Element 1 of this Tuple17

_10

Element 10 of this Tuple17

_11

Element 11 of this Tuple17

_12

Element 12 of this Tuple17

_13

Element 13 of this Tuple17

_14

Element 14 of this Tuple17

_15

Element 15 of this Tuple17

_16

Element 16 of this Tuple17

_17

Element 17 of this Tuple17

_2

Element 2 of this Tuple17

_3

Element 3 of this Tuple17

_4

Element 4 of this Tuple17

_5

Element 5 of this Tuple17

_6

Element 6 of this Tuple17

_7

Element 7 of this Tuple17

_8

Element 8 of this Tuple17

_9

Element 9 of this Tuple17

Attributes

Constructor

Create a new tuple with 17 elements. Note that it is more idiomatic to create a Tuple17 via(t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15, t16, t17)

Source
Tuple17.scala
Supertypes
traitProduct17[T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17]
classT1*:T2*:T3*:T4*:T5*:T6*:T7*:T8*:T9*:T10*:T11*:T12*:T13*:T14*:T15*:T16*:T17*:EmptyTuple.type
traitTuple
traitProduct
traitEquals
classObject
traitMatchable
classAny
Show all
final caseclassTuple18[+T1,+T2,+T3,+T4,+T5,+T6,+T7,+T8,+T9,+T10,+T11,+T12,+T13,+T14,+T15,+T16,+T17,+T18](_1:T1,_2:T2,_3:T3,_4:T4,_5:T5,_6:T6,_7:T7,_8:T8,_9:T9,_10:T10,_11:T11,_12:T12,_13:T13,_14:T14,_15:T15,_16:T16,_17:T17,_18:T18) extendsProduct18[T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18]

A tuple of 18 elements; the canonical representation of ascala.Product18.

A tuple of 18 elements; the canonical representation of ascala.Product18.

Value parameters

_1

Element 1 of this Tuple18

_10

Element 10 of this Tuple18

_11

Element 11 of this Tuple18

_12

Element 12 of this Tuple18

_13

Element 13 of this Tuple18

_14

Element 14 of this Tuple18

_15

Element 15 of this Tuple18

_16

Element 16 of this Tuple18

_17

Element 17 of this Tuple18

_18

Element 18 of this Tuple18

_2

Element 2 of this Tuple18

_3

Element 3 of this Tuple18

_4

Element 4 of this Tuple18

_5

Element 5 of this Tuple18

_6

Element 6 of this Tuple18

_7

Element 7 of this Tuple18

_8

Element 8 of this Tuple18

_9

Element 9 of this Tuple18

Attributes

Constructor

Create a new tuple with 18 elements. Note that it is more idiomatic to create a Tuple18 via(t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15, t16, t17, t18)

Source
Tuple18.scala
Supertypes
traitProduct18[T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18]
classT1*:T2*:T3*:T4*:T5*:T6*:T7*:T8*:T9*:T10*:T11*:T12*:T13*:T14*:T15*:T16*:T17*:T18*:EmptyTuple.type
traitTuple
traitProduct
traitEquals
classObject
traitMatchable
classAny
Show all
final caseclassTuple19[+T1,+T2,+T3,+T4,+T5,+T6,+T7,+T8,+T9,+T10,+T11,+T12,+T13,+T14,+T15,+T16,+T17,+T18,+T19](_1:T1,_2:T2,_3:T3,_4:T4,_5:T5,_6:T6,_7:T7,_8:T8,_9:T9,_10:T10,_11:T11,_12:T12,_13:T13,_14:T14,_15:T15,_16:T16,_17:T17,_18:T18,_19:T19) extendsProduct19[T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19]

A tuple of 19 elements; the canonical representation of ascala.Product19.

A tuple of 19 elements; the canonical representation of ascala.Product19.

Value parameters

_1

Element 1 of this Tuple19

_10

Element 10 of this Tuple19

_11

Element 11 of this Tuple19

_12

Element 12 of this Tuple19

_13

Element 13 of this Tuple19

_14

Element 14 of this Tuple19

_15

Element 15 of this Tuple19

_16

Element 16 of this Tuple19

_17

Element 17 of this Tuple19

_18

Element 18 of this Tuple19

_19

Element 19 of this Tuple19

_2

Element 2 of this Tuple19

_3

Element 3 of this Tuple19

_4

Element 4 of this Tuple19

_5

Element 5 of this Tuple19

_6

Element 6 of this Tuple19

_7

Element 7 of this Tuple19

_8

Element 8 of this Tuple19

_9

Element 9 of this Tuple19

Attributes

Constructor

Create a new tuple with 19 elements. Note that it is more idiomatic to create a Tuple19 via(t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15, t16, t17, t18, t19)

Source
Tuple19.scala
Supertypes
traitProduct19[T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19]
classT1*:T2*:T3*:T4*:T5*:T6*:T7*:T8*:T9*:T10*:T11*:T12*:T13*:T14*:T15*:T16*:T17*:T18*:T19*:EmptyTuple.type
traitTuple
traitProduct
traitEquals
classObject
traitMatchable
classAny
Show all
final caseclassTuple2[+T1,+T2](_1:T1,_2:T2) extendsProduct2[T1,T2]

A tuple of 2 elements; the canonical representation of ascala.Product2.

A tuple of 2 elements; the canonical representation of ascala.Product2.

Value parameters

_1

Element 1 of this Tuple2

_2

Element 2 of this Tuple2

Attributes

Constructor

Create a new tuple with 2 elements. Note that it is more idiomatic to create a Tuple2 via(t1, t2)

Source
Tuple2.scala
Supertypes
traitProduct2[T1,T2]
classT1*:T2*:EmptyTuple.type
traitTuple
traitProduct
traitEquals
classObject
traitMatchable
classAny
Show all
final caseclassTuple20[+T1,+T2,+T3,+T4,+T5,+T6,+T7,+T8,+T9,+T10,+T11,+T12,+T13,+T14,+T15,+T16,+T17,+T18,+T19,+T20](_1:T1,_2:T2,_3:T3,_4:T4,_5:T5,_6:T6,_7:T7,_8:T8,_9:T9,_10:T10,_11:T11,_12:T12,_13:T13,_14:T14,_15:T15,_16:T16,_17:T17,_18:T18,_19:T19,_20:T20) extendsProduct20[T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20]

A tuple of 20 elements; the canonical representation of ascala.Product20.

A tuple of 20 elements; the canonical representation of ascala.Product20.

Value parameters

_1

Element 1 of this Tuple20

_10

Element 10 of this Tuple20

_11

Element 11 of this Tuple20

_12

Element 12 of this Tuple20

_13

Element 13 of this Tuple20

_14

Element 14 of this Tuple20

_15

Element 15 of this Tuple20

_16

Element 16 of this Tuple20

_17

Element 17 of this Tuple20

_18

Element 18 of this Tuple20

_19

Element 19 of this Tuple20

_2

Element 2 of this Tuple20

_20

Element 20 of this Tuple20

_3

Element 3 of this Tuple20

_4

Element 4 of this Tuple20

_5

Element 5 of this Tuple20

_6

Element 6 of this Tuple20

_7

Element 7 of this Tuple20

_8

Element 8 of this Tuple20

_9

Element 9 of this Tuple20

Attributes

Constructor

Create a new tuple with 20 elements. Note that it is more idiomatic to create a Tuple20 via(t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15, t16, t17, t18, t19, t20)

Source
Tuple20.scala
Supertypes
traitProduct20[T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20]
classT1*:T2*:T3*:T4*:T5*:T6*:T7*:T8*:T9*:T10*:T11*:T12*:T13*:T14*:T15*:T16*:T17*:T18*:T19*:T20*:EmptyTuple.type
traitTuple
traitProduct
traitEquals
classObject
traitMatchable
classAny
Show all
final caseclassTuple21[+T1,+T2,+T3,+T4,+T5,+T6,+T7,+T8,+T9,+T10,+T11,+T12,+T13,+T14,+T15,+T16,+T17,+T18,+T19,+T20,+T21](_1:T1,_2:T2,_3:T3,_4:T4,_5:T5,_6:T6,_7:T7,_8:T8,_9:T9,_10:T10,_11:T11,_12:T12,_13:T13,_14:T14,_15:T15,_16:T16,_17:T17,_18:T18,_19:T19,_20:T20,_21:T21) extendsProduct21[T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21]

A tuple of 21 elements; the canonical representation of ascala.Product21.

A tuple of 21 elements; the canonical representation of ascala.Product21.

Value parameters

_1

Element 1 of this Tuple21

_10

Element 10 of this Tuple21

_11

Element 11 of this Tuple21

_12

Element 12 of this Tuple21

_13

Element 13 of this Tuple21

_14

Element 14 of this Tuple21

_15

Element 15 of this Tuple21

_16

Element 16 of this Tuple21

_17

Element 17 of this Tuple21

_18

Element 18 of this Tuple21

_19

Element 19 of this Tuple21

_2

Element 2 of this Tuple21

_20

Element 20 of this Tuple21

_21

Element 21 of this Tuple21

_3

Element 3 of this Tuple21

_4

Element 4 of this Tuple21

_5

Element 5 of this Tuple21

_6

Element 6 of this Tuple21

_7

Element 7 of this Tuple21

_8

Element 8 of this Tuple21

_9

Element 9 of this Tuple21

Attributes

Constructor

Create a new tuple with 21 elements. Note that it is more idiomatic to create a Tuple21 via(t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15, t16, t17, t18, t19, t20, t21)

Source
Tuple21.scala
Supertypes
traitProduct21[T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21]
classT1*:T2*:T3*:T4*:T5*:T6*:T7*:T8*:T9*:T10*:T11*:T12*:T13*:T14*:T15*:T16*:T17*:T18*:T19*:T20*:T21*:EmptyTuple.type
traitTuple
traitProduct
traitEquals
classObject
traitMatchable
classAny
Show all
final caseclassTuple22[+T1,+T2,+T3,+T4,+T5,+T6,+T7,+T8,+T9,+T10,+T11,+T12,+T13,+T14,+T15,+T16,+T17,+T18,+T19,+T20,+T21,+T22](_1:T1,_2:T2,_3:T3,_4:T4,_5:T5,_6:T6,_7:T7,_8:T8,_9:T9,_10:T10,_11:T11,_12:T12,_13:T13,_14:T14,_15:T15,_16:T16,_17:T17,_18:T18,_19:T19,_20:T20,_21:T21,_22:T22) extendsProduct22[T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22]

A tuple of 22 elements; the canonical representation of ascala.Product22.

A tuple of 22 elements; the canonical representation of ascala.Product22.

Value parameters

_1

Element 1 of this Tuple22

_10

Element 10 of this Tuple22

_11

Element 11 of this Tuple22

_12

Element 12 of this Tuple22

_13

Element 13 of this Tuple22

_14

Element 14 of this Tuple22

_15

Element 15 of this Tuple22

_16

Element 16 of this Tuple22

_17

Element 17 of this Tuple22

_18

Element 18 of this Tuple22

_19

Element 19 of this Tuple22

_2

Element 2 of this Tuple22

_20

Element 20 of this Tuple22

_21

Element 21 of this Tuple22

_22

Element 22 of this Tuple22

_3

Element 3 of this Tuple22

_4

Element 4 of this Tuple22

_5

Element 5 of this Tuple22

_6

Element 6 of this Tuple22

_7

Element 7 of this Tuple22

_8

Element 8 of this Tuple22

_9

Element 9 of this Tuple22

Attributes

Constructor

Create a new tuple with 22 elements. Note that it is more idiomatic to create a Tuple22 via(t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15, t16, t17, t18, t19, t20, t21, t22)

Source
Tuple22.scala
Supertypes
traitProduct22[T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22]
classT1*:T2*:T3*:T4*:T5*:T6*:T7*:T8*:T9*:T10*:T11*:T12*:T13*:T14*:T15*:T16*:T17*:T18*:T19*:T20*:T21*:T22*:EmptyTuple.type
traitTuple
traitProduct
traitEquals
classObject
traitMatchable
classAny
Show all
final caseclassTuple3[+T1,+T2,+T3](_1:T1,_2:T2,_3:T3) extendsProduct3[T1,T2,T3]

A tuple of 3 elements; the canonical representation of ascala.Product3.

A tuple of 3 elements; the canonical representation of ascala.Product3.

Value parameters

_1

Element 1 of this Tuple3

_2

Element 2 of this Tuple3

_3

Element 3 of this Tuple3

Attributes

Constructor

Create a new tuple with 3 elements. Note that it is more idiomatic to create a Tuple3 via(t1, t2, t3)

Source
Tuple3.scala
Supertypes
traitProduct3[T1,T2,T3]
classT1*:T2*:T3*:EmptyTuple.type
traitTuple
traitProduct
traitEquals
classObject
traitMatchable
classAny
Show all
final caseclassTuple4[+T1,+T2,+T3,+T4](_1:T1,_2:T2,_3:T3,_4:T4) extendsProduct4[T1,T2,T3,T4]

A tuple of 4 elements; the canonical representation of ascala.Product4.

A tuple of 4 elements; the canonical representation of ascala.Product4.

Value parameters

_1

Element 1 of this Tuple4

_2

Element 2 of this Tuple4

_3

Element 3 of this Tuple4

_4

Element 4 of this Tuple4

Attributes

Constructor

Create a new tuple with 4 elements. Note that it is more idiomatic to create a Tuple4 via(t1, t2, t3, t4)

Source
Tuple4.scala
Supertypes
traitProduct4[T1,T2,T3,T4]
classT1*:T2*:T3*:T4*:EmptyTuple.type
traitTuple
traitProduct
traitEquals
classObject
traitMatchable
classAny
Show all
final caseclassTuple5[+T1,+T2,+T3,+T4,+T5](_1:T1,_2:T2,_3:T3,_4:T4,_5:T5) extendsProduct5[T1,T2,T3,T4,T5]

A tuple of 5 elements; the canonical representation of ascala.Product5.

A tuple of 5 elements; the canonical representation of ascala.Product5.

Value parameters

_1

Element 1 of this Tuple5

_2

Element 2 of this Tuple5

_3

Element 3 of this Tuple5

_4

Element 4 of this Tuple5

_5

Element 5 of this Tuple5

Attributes

Constructor

Create a new tuple with 5 elements. Note that it is more idiomatic to create a Tuple5 via(t1, t2, t3, t4, t5)

Source
Tuple5.scala
Supertypes
traitProduct5[T1,T2,T3,T4,T5]
classT1*:T2*:T3*:T4*:T5*:EmptyTuple.type
traitTuple
traitProduct
traitEquals
classObject
traitMatchable
classAny
Show all
final caseclassTuple6[+T1,+T2,+T3,+T4,+T5,+T6](_1:T1,_2:T2,_3:T3,_4:T4,_5:T5,_6:T6) extendsProduct6[T1,T2,T3,T4,T5,T6]

A tuple of 6 elements; the canonical representation of ascala.Product6.

A tuple of 6 elements; the canonical representation of ascala.Product6.

Value parameters

_1

Element 1 of this Tuple6

_2

Element 2 of this Tuple6

_3

Element 3 of this Tuple6

_4

Element 4 of this Tuple6

_5

Element 5 of this Tuple6

_6

Element 6 of this Tuple6

Attributes

Constructor

Create a new tuple with 6 elements. Note that it is more idiomatic to create a Tuple6 via(t1, t2, t3, t4, t5, t6)

Source
Tuple6.scala
Supertypes
traitProduct6[T1,T2,T3,T4,T5,T6]
classT1*:T2*:T3*:T4*:T5*:T6*:EmptyTuple.type
traitTuple
traitProduct
traitEquals
classObject
traitMatchable
classAny
Show all
final caseclassTuple7[+T1,+T2,+T3,+T4,+T5,+T6,+T7](_1:T1,_2:T2,_3:T3,_4:T4,_5:T5,_6:T6,_7:T7) extendsProduct7[T1,T2,T3,T4,T5,T6,T7]

A tuple of 7 elements; the canonical representation of ascala.Product7.

A tuple of 7 elements; the canonical representation of ascala.Product7.

Value parameters

_1

Element 1 of this Tuple7

_2

Element 2 of this Tuple7

_3

Element 3 of this Tuple7

_4

Element 4 of this Tuple7

_5

Element 5 of this Tuple7

_6

Element 6 of this Tuple7

_7

Element 7 of this Tuple7

Attributes

Constructor

Create a new tuple with 7 elements. Note that it is more idiomatic to create a Tuple7 via(t1, t2, t3, t4, t5, t6, t7)

Source
Tuple7.scala
Supertypes
traitProduct7[T1,T2,T3,T4,T5,T6,T7]
classT1*:T2*:T3*:T4*:T5*:T6*:T7*:EmptyTuple.type
traitTuple
traitProduct
traitEquals
classObject
traitMatchable
classAny
Show all
final caseclassTuple8[+T1,+T2,+T3,+T4,+T5,+T6,+T7,+T8](_1:T1,_2:T2,_3:T3,_4:T4,_5:T5,_6:T6,_7:T7,_8:T8) extendsProduct8[T1,T2,T3,T4,T5,T6,T7,T8]

A tuple of 8 elements; the canonical representation of ascala.Product8.

A tuple of 8 elements; the canonical representation of ascala.Product8.

Value parameters

_1

Element 1 of this Tuple8

_2

Element 2 of this Tuple8

_3

Element 3 of this Tuple8

_4

Element 4 of this Tuple8

_5

Element 5 of this Tuple8

_6

Element 6 of this Tuple8

_7

Element 7 of this Tuple8

_8

Element 8 of this Tuple8

Attributes

Constructor

Create a new tuple with 8 elements. Note that it is more idiomatic to create a Tuple8 via(t1, t2, t3, t4, t5, t6, t7, t8)

Source
Tuple8.scala
Supertypes
traitProduct8[T1,T2,T3,T4,T5,T6,T7,T8]
classT1*:T2*:T3*:T4*:T5*:T6*:T7*:T8*:EmptyTuple.type
traitTuple
traitProduct
traitEquals
classObject
traitMatchable
classAny
Show all
final caseclassTuple9[+T1,+T2,+T3,+T4,+T5,+T6,+T7,+T8,+T9](_1:T1,_2:T2,_3:T3,_4:T4,_5:T5,_6:T6,_7:T7,_8:T8,_9:T9) extendsProduct9[T1,T2,T3,T4,T5,T6,T7,T8,T9]

A tuple of 9 elements; the canonical representation of ascala.Product9.

A tuple of 9 elements; the canonical representation of ascala.Product9.

Value parameters

_1

Element 1 of this Tuple9

_2

Element 2 of this Tuple9

_3

Element 3 of this Tuple9

_4

Element 4 of this Tuple9

_5

Element 5 of this Tuple9

_6

Element 6 of this Tuple9

_7

Element 7 of this Tuple9

_8

Element 8 of this Tuple9

_9

Element 9 of this Tuple9

Attributes

Constructor

Create a new tuple with 9 elements. Note that it is more idiomatic to create a Tuple9 via(t1, t2, t3, t4, t5, t6, t7, t8, t9)

Source
Tuple9.scala
Supertypes
traitProduct9[T1,T2,T3,T4,T5,T6,T7,T8,T9]
classT1*:T2*:T3*:T4*:T5*:T6*:T7*:T8*:T9*:EmptyTuple.type
traitTuple
traitProduct
traitEquals
classObject
traitMatchable
classAny
Show all

This class implements errors which are thrown whenever a field is used before it has been initialized.

This class implements errors which are thrown whenever a field is used before it has been initialized.

Such runtime checks are not emitted by default. They can be enabled by the-Xcheckinit compiler option.

Attributes

Source
UninitializedFieldError.scala
Supertypes
traitProduct
traitEquals
classException
classThrowable
classObject
traitMatchable
classAny
Show all
final abstractclassUnit() extendsAnyVal

Unit is a subtype ofscala.AnyVal.

Unit is a subtype ofscala.AnyVal. There is only one value of typeUnit,(), and it is not represented by any object in the underlying runtime system. A method with return typeUnit is analogous to a Java method which is declaredvoid.

Attributes

Companion
object
Source
Unit.scala
Supertypes
classAnyVal
traitMatchable
classAny
objectUnit

Attributes

Companion
class
Source
Unit.scala
Supertypes
classObject
traitMatchable
classAny
Self type
Unit.type
finalclassValueOf[T](valvalue:T) extendsAnyVal

ValueOf[T] provides the unique value of the typeT whereT is a type which has a single inhabitant.

ValueOf[T] provides the unique value of the typeT whereT is a type which has a single inhabitant. Eligible types are singleton types of the formstablePath.type, Unit and singleton types corresponding to value literals.

The value itself can conveniently be retrieved withPredef#valueOf, which requires aValueOf to be available in implicit scope.

The compiler provides instances ofValueOf[T] for all eligible types. Typically an instance would be required where a runtime value corresponding to a type level computation is needed.

For example, we might define a typeResidue[M <: Int] corresponding to the group of integers moduloM. We could then mandate that residues can be summed only when they are parameterized by the same modulus,

case class Residue[M <: Int](n: Int) extends AnyVal { def +(rhs: Residue[M])(implicit m: ValueOf[M]): Residue[M] =   Residue((this.n + rhs.n) % valueOf[M])}val fiveModTen = Residue[10](5)val nineModTen = Residue[10](9)fiveModTen + nineModTen    // OK == Residue[10](4)val fourModEleven = Residue[11](4)fiveModTen + fourModEleven // compiler error: type mismatch;                          //   found   : Residue[11]                          //   required: Residue[10]

Notice that here the modulus is encoded in the type of the values and so does not incur any additional per-value storage cost. When a runtime value of the modulus is required in the implementation of+ it is provided at the call site via the implicit argumentm of typeValueOf[M].

Attributes

Source
ValueOf.scala
Supertypes
classAnyVal
traitMatchable
classAny
classdeprecated(message:String = ...,since:String = ...) extendsConstantAnnotation

An annotation that designates that a definition is deprecated.

An annotation that designates that a definition is deprecated. A deprecation warning is issued upon usage of the annotated definition.

Library authors should state the library's deprecation policy in their documentation to give developers guidance on how long a deprecated definition will be preserved.

Library authors should prepend the name of their library to the version number to help developers distinguish deprecations coming from different libraries:

@deprecated("this method will be removed", "FooLib 12.0")def oldMethod(x: Int) = ...

The compiler will emit deprecation warnings grouped by library and version:

oldMethod(1)oldMethod(2)aDeprecatedMethodFromLibraryBar(3, 4)// warning: there was one deprecation warning (since BarLib 3.2)// warning: there were two deprecation warnings (since FooLib 12.0)// warning: there were three deprecation warnings in total; re-run with -deprecation for details

The Scala compiler also warns about using definitions annotated withjava.lang.Deprecated. However it is recommended to use the Scala@deprecated annotation in Scala code because it allows providing a deprecation message.

@deprecated in the Scala language and its standard library

A deprecated element of the Scala language or a definition in the Scala standard library will be preserved at least for the current major version.

This means that an element deprecated in some 2.13.x release will be preserved in all 2.13.x releases, but may be removed in the future. (A deprecated element might be kept longer to ease migration, but developers should not rely on this.)

Value parameters

message

the message to print during compilation if the definition is accessed

since

a string identifying the first version in which the definition was deprecated

Attributes

See also
Source
deprecated.scala
Supertypes
classObject
traitMatchable
classAny
Show all
finalclassdeprecatedInheritance(message:String = ...,since:String = ...) extendsConstantAnnotation

An annotation that designates that inheriting from a class is deprecated.

An annotation that designates that inheriting from a class is deprecated.

This is usually done to warn about a non-final class being made final in a future version. Sub-classing such a class then generates a warning.

No warnings are generated if the subclass is in the same compilation unit.

Library authors should state the library's deprecation policy in their documentation to give developers guidance on when a type annotated with@deprecatedInheritance will befinalized.

Library authors should prepend the name of their library to the version number to help developers distinguish deprecations coming from different libraries:

@deprecatedInheritance("this class will be made final", "FooLib 12.0")class Foo
val foo = new Foo     // no deprecation warningclass Bar extends Foo// warning: inheritance from class Foo is deprecated (since FooLib 12.0): this class will be made final// class Bar extends Foo//                   ^

Value parameters

message

the message to print during compilation if the class was sub-classed

since

a string identifying the first version in which inheritance was deprecated

Attributes

See also
Source
deprecatedInheritance.scala
Supertypes
classObject
traitMatchable
classAny
Show all
classdeprecatedName(name:String = ...,since:String = ...) extendsStaticAnnotation

An annotation that designates that the name of a parameter is deprecated.

An annotation that designates that the name of a parameter is deprecated.

Using this name in a named argument generates a deprecation warning.

If thename is omitted, then using the canonical name is deprecated. In that case, lints such as-Xlint:named-booleans which encourage the use of a name will not warn.

Library authors should state the library's deprecation policy in their documentation to give developers guidance on how long a deprecated name will be preserved.

Library authors should prepend the name of their library to the version number to help developers distinguish deprecations coming from different libraries:

def inc(x: Int, @deprecatedName("y", "FooLib 12.0") n: Int): Int = x + ninc(1, y = 2)

will produce the following warning:

warning: the parameter name y is deprecated (since FooLib 12.0): use n insteadinc(1, y = 2)         ^

Attributes

See also
Source
deprecatedName.scala
Supertypes
classObject
traitMatchable
classAny
classdeprecatedOverriding(message:String = ...,since:String = ...) extendsConstantAnnotation

An annotation that designates that overriding a member is deprecated.

An annotation that designates that overriding a member is deprecated.

Overriding such a member in a sub-class then generates a warning.

Library authors should state the library's deprecation policy in their documentation to give developers guidance on when a method annotated with@deprecatedOverriding will befinalized.

Library authors should prepend the name of their library to the version number to help developers distinguish deprecations coming from different libraries:

class Foo {  @deprecatedOverriding("this method will be made final", "FooLib 12.0")  def add(x: Int, y: Int) = x + y}
class Bar extends Foo // no deprecation warningclass Baz extends Foo {  override def add(x: Int, y: Int) = x - y}// warning: overriding method add in class Foo is deprecated (since FooLib 12.0): this method will be made final// override def add(x: Int, y: Int) = x - y//              ^

Value parameters

message

the message to print during compilation if the member was overridden

since

a string identifying the first version in which overriding was deprecated

Attributes

See also
Source
deprecatedOverriding.scala
Supertypes
classObject
traitMatchable
classAny
Show all

An annotation for methods that the optimizer should inline.

An annotation for methods that the optimizer should inline.

Note that by default, the Scala optimizer is disabled and no callsites are inlined. See-opt:help andthe overview document for information on how to enable the optimizer and inliner.

When inlining is enabled, the inliner will always try to inline methods or callsites annotated@inline (under the condition that inlining from the defining class is allowed). If inlining is not possible, for example because the method is not final, an optimizer warning will be issued. See-Wopt:help for details.

Examples:

@inline   final def f1(x: Int) = x@noinline final def f2(x: Int) = x         final def f3(x: Int) = xdef t1 = f1(1)              // inlined if possibledef t2 = f2(1)              // not inlineddef t3 = f3(1)              // may be inlined (the inliner heuristics can select the callsite)def t4 = f1(1): @noinline   // not inlined (override at callsite)def t5 = f2(1): @inline     // inlined if possible (override at callsite)def t6 = f3(1): @inline     // inlined if possibledef t7 = f3(1): @noinline   // not inlined}

Note: parentheses are required when annotating a callsite within a larger expression.

def t1 = f1(1) + f1(1): @noinline   // equivalent to (f1(1) + f1(1)): @noinlinedef t2 = f1(1) + (f1(1): @noinline) // the second call to f1 is not inlined

Attributes

Source
inline.scala
Supertypes
classObject
traitMatchable
classAny
objectlanguage

Thescala.language object controls the language features available to the programmer, as proposed in theSIP-18 document.

Thescala.language object controls the language features available to the programmer, as proposed in theSIP-18 document.

Each of these features has to be explicitly imported into the current scope to become available:

import language.postfixOps // or language._List(1, 2, 3) reverse

The language features are:

Attributes

Source
language.scala
Supertypes
classObject
traitMatchable
classAny
Self type

Attributes

Source
languageFeature.scala
Supertypes
classObject
traitMatchable
classAny
Self type
classmain extendsAnnotation

An annotation that designates a main function

An annotation that designates a main function

Attributes

Source
main.scala
Supertypes
classObject
traitMatchable
classAny

Marker for native methods.

Marker for native methods.

@native def f(x: Int, y: List[Long]): String = ...

A@native method is compiled to the platform's native method, while discarding the method's body (if any). The body will be type checked if present.

A method marked @native must be a member of a class, not a trait (since 2.12).

Attributes

Source
native.scala
Supertypes
classObject
traitMatchable
classAny
finalclassnoinline extendsStaticAnnotation

An annotation for methods that the optimizer should not inline.

An annotation for methods that the optimizer should not inline.

Note that by default, the Scala optimizer is disabled and no callsites are inlined. See-opt:help for information how to enable the optimizer and inliner.

When inlining is enabled, the inliner will never inline methods or callsites annotated@noinline.

Examples:

@inline   final def f1(x: Int) = x@noinline final def f2(x: Int) = x         final def f3(x: Int) = xdef t1 = f1(1)              // inlined if possibledef t2 = f2(1)              // not inlineddef t3 = f3(1)              // may be inlined (the inliner heuristics can select the callsite)def t4 = f1(1): @noinline   // not inlined (override at callsite)def t5 = f2(1): @inline     // inlined if possible (override at callsite)def t6 = f3(1): @inline     // inlined if possibledef t7 = f3(1): @noinline   // not inlined}

Note: parentheses are required when annotating a callsite within a larger expression.

def t1 = f1(1) + f1(1): @noinline   // equivalent to (f1(1) + f1(1)): @noinlinedef t2 = f1(1) + (f1(1): @noinline) // the second call to f1 is not inlined

Attributes

Source
noinline.scala
Supertypes
classObject
traitMatchable
classAny

Annotate type parameters on which code should be automatically specialized.

Annotate type parameters on which code should be automatically specialized. For example:

class MyList[@specialized T] ...

Type T can be specialized on a subset of the primitive types by specifying a list of primitive types to specialize at:

class MyList[@specialized(Int, Double, Boolean) T] ..

Attributes

Source
specialized.scala
Supertypes
classObject
traitMatchable
classAny
finalclassthrows[T <:Throwable](cause:String = ...) extendsStaticAnnotation

Annotation for specifying the exceptions thrown by a method.

Annotation for specifying the exceptions thrown by a method. For example:

class Reader(fname: String) { private val in = new BufferedReader(new FileReader(fname)) @throws[IOException]("if the file doesn't exist") def read() = in.read()}

Attributes

Source
throws.scala
Supertypes
classObject
traitMatchable
classAny
finalclasstransient extendsStaticAnnotation

Attributes

Source
transient.scala
Supertypes
classObject
traitMatchable
classAny
finalclassunchecked extendsAnnotation

An annotation to designate that the annotated entity should not be considered for additional compiler checks.

An annotation to designate that the annotated entity should not be considered for additional compiler checks. Specific applications include annotating the subject of a match expression to suppress exhaustiveness and reachability warnings, and annotating a type argument in a match case to suppress unchecked warnings.

Such suppression should be used with caution, without which one may encounterscala.MatchError orjava.lang.ClassCastException at runtime. In most cases one can and should address the warning instead of suppressing it.

object Test extends App {  // This would normally warn "match is not exhaustive"  // because `None` is not covered.  def f(x: Option[String]) = (x: @unchecked) match { case Some(y) => y }  // This would normally warn "type pattern is unchecked"  // but here will blindly cast the head element to String.  def g(xs: Any) = xs match { case x: List[String @unchecked] => x.head }}

Attributes

Source
unchecked.scala
Supertypes
classObject
traitMatchable
classAny
finalclassvolatile extendsStaticAnnotation

Attributes

Source
volatile.scala
Supertypes
classObject
traitMatchable
classAny

Deprecated classlikes

Classes and objects (but note, not traits) inheriting theDelayedInit marker trait will have their initialization code rewritten as follows:code becomesdelayedInit(code).

Classes and objects (but note, not traits) inheriting theDelayedInit marker trait will have their initialization code rewritten as follows:code becomesdelayedInit(code).

Initialization code comprises all statements and all value definitions that are executed during initialization.

Example:

trait Helper extends DelayedInit {  def delayedInit(body: => Unit) = {    println("dummy text, printed before initialization of C")    body // evaluates the initialization code of C  }}class C extends Helper {  println("this is the initialization code of C")}object Test extends App {  val c = new C}

Should result in the following being printed:

dummy text, printed before initialization of Cthis is the initialization code of C

Attributes

See also

"Delayed Initialization" subsection of the Scala Language Specification (section 5.1)

Deprecated
[Since version 2.11.0]DelayedInit semantics can be surprising. Support for `App` will continue. See the release notes for more details: https://github.com/scala/scala/releases/tag/v2.11.0
Source
DelayedInit.scala
Supertypes
classObject
traitMatchable
classAny
Known subtypes
traitApp
traitProxy

This class implements a simple proxy that forwards all calls to the public, non-final methods defined in classAny to another object self.

This class implements a simple proxy that forwards all calls to the public, non-final methods defined in classAny to another object self. Those methods are:

def hashCode(): Intdef equals(other: Any): Booleandef toString(): String

Note: forwarding methods in this way will most likely create an asymmetric equals method, which is not generally recommended.

Attributes

Companion
object
Deprecated
[Since version 2.13.0]Explicitly override hashCode, equals and toString instead.
Source
Proxy.scala
Supertypes
classAny
Known subtypes
classSoftReference[T]
classWeakReference[T]
traitTyped[T]
traitOrderedProxy[T]
classRichFloat
classRichInt
traitIntegralProxy[T]
classRichChar
classRichLong
classRichByte
classRichShort
traitRangedProxy[T]
Show all
objectProxy

Attributes

Companion
trait
Deprecated
[Since version 2.13.0]All members of this object are deprecated.
Source
Proxy.scala
Supertypes
classObject
traitMatchable
classAny
Self type
Proxy.type

This class represents uninitialized variable/value errors.

This class represents uninitialized variable/value errors.

Attributes

Deprecated
[Since version 2.12.7]will be removed in a future release
Source
UninitializedError.scala
Supertypes
classException
classThrowable
classObject
traitMatchable
classAny
Show all

Experimental classlikes

classCanThrow[-E <:Exception] extendsControl,Erased

A capability class that allows to throw exceptionE. When used with the experimental.saferExceptions feature, athrow Ex() expression will require a given of classCanThrow[Ex] to be available.

A capability class that allows to throw exceptionE. When used with the experimental.saferExceptions feature, athrow Ex() expression will require a given of classCanThrow[Ex] to be available.

Attributes

Experimental
true
Source
CanThrow.scala
Supertypes
traitErased
traitControl
traitSharable
classObject
traitMatchable
classAny
Show all
traitPrecise extendsErased

A type class-like trait intended as a context bound for type variables. If we have[X: Precise], instances of the type variableX are inferred in precise mode. This means that singleton types and union types are not widened.

A type class-like trait intended as a context bound for type variables. If we have[X: Precise], instances of the type variableX are inferred in precise mode. This means that singleton types and union types are not widened.

Attributes

Experimental
true
Source
Precise.scala
Supertypes
traitErased
classObject
traitMatchable
classAny
traitPure

A marker trait that declares that all inheriting classes are "pure" in the sense that their values retain no capabilities including capabilities needed to perform effects. This has formal meaning only under capture checking.

A marker trait that declares that all inheriting classes are "pure" in the sense that their values retain no capabilities including capabilities needed to perform effects. This has formal meaning only under capture checking.

Attributes

Experimental
true
Source
Pure.scala
Supertypes
classObject
traitMatchable
classAny
Self type

Attributes

Experimental
true
Source
CanThrow.scala
Supertypes
classObject
traitMatchable
classAny
Self type

Types

type& =[X0,X1] =>>X0 &X1

The intersection of two types.

type::[+A] =::[A]

Attributes

Source
package.scala

Attributes

Source
package.scala

Attributes

Source
package.scala

Attributes

Source
package.scala
typeEither[+A,+B] =Either[A,B]

Attributes

Source
package.scala

A tuple of 0 elements

A tuple of 0 elements

Attributes

Source
Tuple.scala
typeEquiv[T] =Equiv[T]

Attributes

Source
package.scala

Attributes

Source
package.scala

Attributes

Source
package.scala

Attributes

Source
package.scala
opaquetypeIArray[+T]

Attributes

Source
IArray.scala

Attributes

Source
package.scala
typeIntegral[T] =Integral[T]

Attributes

Source
package.scala
typeIterable[+A] =Iterable[A]

Attributes

Source
package.scala

Attributes

Source
package.scala
typeIterator[+A] =Iterator[A]

Attributes

Source
package.scala
typeLazyList[+A] =LazyList[A]

Attributes

Source
package.scala
typeLeft[+A,+B] =Left[A,B]

Attributes

Source
package.scala
typeList[+A] =List[A]

Attributes

Source
package.scala
typeNumeric[T] =Numeric[T]

Attributes

Source
package.scala
typeOrdered[T] =Ordered[T]

Attributes

Source
package.scala
typeOrdering[T] =Ordering[T]

Attributes

Source
package.scala

Attributes

Source
package.scala

Attributes

Source
package.scala
typeRight[+A,+B] =Right[A,B]

Attributes

Source
package.scala
typeSeq[+A] =Seq[A]

Attributes

Source
package.scala

Attributes

Source
package.scala
typeVector[+A] =Vector[A]

Attributes

Source
package.scala
type| =[X0,X1] =>>X0 |X1

The union of two types.

Deprecated types

Attributes

Deprecated
[Since version 2.13.0]Use scala.collection.BufferedIterator instead of scala.BufferedIterator
Source
package.scala
typeStream[+A] =Stream[A]

Attributes

Deprecated
[Since version 2.13.0]Use LazyList instead of Stream
Source
package.scala
typeTraversable[+A] =Iterable[A]

Attributes

Deprecated
[Since version 2.13.0]Use Iterable instead of Traversable
Source
package.scala

Attributes

Deprecated
[Since version 2.13.0]Use IterableOnce instead of TraversableOnce
Source
package.scala

Value members

Concrete fields

val+::+:.type

Attributes

Source
package.scala
val:+::+.type

Attributes

Source
package.scala
val:::::.type

Attributes

Source
package.scala

Attributes

Source
package.scala
valBigInt:BigInt.type

Attributes

Source
package.scala
valEither:Either.type

Attributes

Source
package.scala
valEquiv:Equiv.type

Attributes

Source
package.scala

Attributes

Source
package.scala

Attributes

Source
package.scala

Attributes

Source
package.scala

Attributes

Source
package.scala

Attributes

Source
package.scala

Attributes

Source
package.scala
valLeft:Left.type

Attributes

Source
package.scala
valList:List.type

Attributes

Source
package.scala
valNil:Nil.type

Attributes

Source
package.scala

Attributes

Source
package.scala

Attributes

Source
package.scala

Attributes

Source
package.scala
valRange:Range.type

Attributes

Source
package.scala
valRight:Right.type

Attributes

Source
package.scala
valSeq:Seq.type

Attributes

Source
package.scala

Attributes

Source
package.scala
valVector:Vector.type

Attributes

Source
package.scala

Deprecated fields

valStream:Stream.type

Attributes

Deprecated
[Since version 2.13.0]Use LazyList instead of Stream
Source
package.scala

Attributes

Deprecated
[Since version 2.13.0]Use Iterable instead of Traversable
Source
package.scala
In this article
Generated with
Copyright (c) 2002-2025, LAMP/EPFL
Copyright (c) 2002-2025, LAMP/EPFL

[8]ページ先頭

©2009-2025 Movatter.jp