object FunctionConverters extends Priority0FunctionExtensions
This object provides extension methods that convert between Scala and Java function types.
When writing Java code, use the explicit conversion methods defined in javaapi.FunctionConverters instead.
Using the .asJava
extension method on a Scala function produces the most specific possible
Java function type:
scala> import scala.jdk.FunctionConverters._ scala> val f = (x: Int) => x + 1 scala> val jf1 = f.asJava jf1: java.util.function.IntUnaryOperator = ...
More generic Java function types can be created using the corresponding asJavaXYZ
extension
method:
scala> val jf2 = f.asJavaFunction jf2: java.util.function.Function[Int,Int] = ... scala> val jf3 = f.asJavaUnaryOperator jf3: java.util.function.UnaryOperator[Int] = ...
Converting a Java function to Scala is done using the asScala
extension method:
scala> List(1,2,3).map(jf2.asScala) res1: List[Int] = List(2, 3, 4)
- Source
- FunctionConverters.scala
- Alphabetic
- By Inheritance
- FunctionConverters
- Priority0FunctionExtensions
- Priority1FunctionExtensions
- Priority2FunctionExtensions
- Priority3FunctionExtensions
- AnyRef
- Any
- Hide All
- Show All
- Public
- Protected
Value Members
- final def !=(arg0: Any): Boolean
Test two objects for inequality.
Test two objects for inequality.
- returns
true
if !(this == that), false otherwise.
- Definition Classes
- AnyRef → Any
- final def ##: Int
Equivalent to
x.hashCode
except for boxed numeric types andnull
.Equivalent to
x.hashCode
except for boxed numeric types andnull
. For numerics, it returns a hash value which is consistent with value equality: if two value type instances compare as true, then ## will produce the same hash value for each of them. Fornull
returns a hashcode wherenull.hashCode
throws aNullPointerException
.- returns
a hash value consistent with ==
- Definition Classes
- AnyRef → Any
- final def ==(arg0: Any): Boolean
The expression
x == that
is equivalent toif (x eq null) that eq null else x.equals(that)
.The expression
x == that
is equivalent toif (x eq null) that eq null else x.equals(that)
.- returns
true
if the receiver object is equivalent to the argument;false
otherwise.
- Definition Classes
- AnyRef → Any
- final def asInstanceOf[T0]: T0
Cast the receiver object to be of type
T0
.Cast the receiver object to be of type
T0
.Note that the success of a cast at runtime is modulo Scala's erasure semantics. Therefore the expression
1.asInstanceOf[String]
will throw aClassCastException
at runtime, while the expressionList(1).asInstanceOf[List[String]]
will not. In the latter example, because the type argument is erased as part of compilation it is not possible to check whether the contents of the list are of the requested type.- returns
the receiver object.
- Definition Classes
- Any
- Exceptions thrown
ClassCastException
if the receiver object is not an instance of the erasure of typeT0
.
- def clone(): AnyRef
Create a copy of the receiver object.
Create a copy of the receiver object.
The default implementation of the
clone
method is platform dependent.- returns
a copy of the receiver object.
- implicit def enrichAsJavaBiConsumer[T, U](sf: (T, U) => Unit): RichFunction2AsBiConsumer[T, U]
- Definition Classes
- Priority2FunctionExtensions
- Annotations
- @inline()
- implicit def enrichAsJavaBiFunction[T, U, R](sf: (T, U) => R): RichFunction2AsBiFunction[T, U, R]
- Definition Classes
- Priority3FunctionExtensions
- Annotations
- @inline()
- implicit def enrichAsJavaBiPredicate[T, U](sf: (T, U) => Boolean): RichFunction2AsBiPredicate[T, U]
- Definition Classes
- Priority2FunctionExtensions
- Annotations
- @inline()
- implicit def enrichAsJavaBinaryOperator[T, A1, A2](sf: (T, A1) => A2)(implicit evA1: =:=[A1, T], evA2: =:=[A2, T]): RichFunction2AsBinaryOperator[T]
- Definition Classes
- Priority1FunctionExtensions
- Annotations
- @inline()
- implicit def enrichAsJavaBooleanSupplier(sf: () => Boolean): RichFunction0AsBooleanSupplier
- Definition Classes
- Priority0FunctionExtensions
- Annotations
- @inline()
- implicit def enrichAsJavaConsumer[T](sf: (T) => Unit): RichFunction1AsConsumer[T]
- Definition Classes
- Priority1FunctionExtensions
- Annotations
- @inline()
- implicit def enrichAsJavaDoubleBinaryOperator[A0, A1](sf: (A0, A1) => Double)(implicit evA0: =:=[A0, Double], evA1: =:=[A1, Double]): RichFunction2AsDoubleBinaryOperator
- Definition Classes
- Priority0FunctionExtensions
- Annotations
- @inline()
- implicit def enrichAsJavaDoubleConsumer[A0](sf: (A0) => Unit)(implicit evA0: =:=[A0, Double]): RichFunction1AsDoubleConsumer
- Definition Classes
- Priority0FunctionExtensions
- Annotations
- @inline()
- implicit def enrichAsJavaDoubleFunction[A0, R](sf: (A0) => R)(implicit evA0: =:=[A0, Double]): RichFunction1AsDoubleFunction[R]
- Definition Classes
- Priority1FunctionExtensions
- Annotations
- @inline()
- implicit def enrichAsJavaDoublePredicate[A0](sf: (A0) => Boolean)(implicit evA0: =:=[A0, Double]): RichFunction1AsDoublePredicate
- Definition Classes
- Priority0FunctionExtensions
- Annotations
- @inline()
- implicit def enrichAsJavaDoubleSupplier(sf: () => Double): RichFunction0AsDoubleSupplier
- Definition Classes
- Priority0FunctionExtensions
- Annotations
- @inline()
- implicit def enrichAsJavaDoubleToIntFunction[A0](sf: (A0) => Int)(implicit evA0: =:=[A0, Double]): RichFunction1AsDoubleToIntFunction
- Definition Classes
- Priority0FunctionExtensions
- Annotations
- @inline()
- implicit def enrichAsJavaDoubleToLongFunction[A0](sf: (A0) => Long)(implicit evA0: =:=[A0, Double]): RichFunction1AsDoubleToLongFunction
- Definition Classes
- Priority0FunctionExtensions
- Annotations
- @inline()
- implicit def enrichAsJavaDoubleUnaryOperator[A0](sf: (A0) => Double)(implicit evA0: =:=[A0, Double]): RichFunction1AsDoubleUnaryOperator
- Definition Classes
- Priority0FunctionExtensions
- Annotations
- @inline()
- implicit def enrichAsJavaFunction[T, R](sf: (T) => R): RichFunction1AsFunction[T, R]
- Definition Classes
- Priority2FunctionExtensions
- Annotations
- @inline()
- implicit def enrichAsJavaIntBinaryOperator[A0, A1](sf: (A0, A1) => Int)(implicit evA0: =:=[A0, Int], evA1: =:=[A1, Int]): RichFunction2AsIntBinaryOperator
- Definition Classes
- Priority0FunctionExtensions
- Annotations
- @inline()
- implicit def enrichAsJavaIntConsumer[A0](sf: (A0) => Unit)(implicit evA0: =:=[A0, Int]): RichFunction1AsIntConsumer
- Definition Classes
- Priority0FunctionExtensions
- Annotations
- @inline()
- implicit def enrichAsJavaIntFunction[A0, R](sf: (A0) => R)(implicit evA0: =:=[A0, Int]): RichFunction1AsIntFunction[R]
- Definition Classes
- Priority1FunctionExtensions
- Annotations
- @inline()
- implicit def enrichAsJavaIntPredicate[A0](sf: (A0) => Boolean)(implicit evA0: =:=[A0, Int]): RichFunction1AsIntPredicate
- Definition Classes
- Priority0FunctionExtensions
- Annotations
- @inline()
- implicit def enrichAsJavaIntSupplier(sf: () => Int): RichFunction0AsIntSupplier
- Definition Classes
- Priority0FunctionExtensions
- Annotations
- @inline()
- implicit def enrichAsJavaIntToDoubleFunction[A0](sf: (A0) => Double)(implicit evA0: =:=[A0, Int]): RichFunction1AsIntToDoubleFunction
- Definition Classes
- Priority0FunctionExtensions
- Annotations
- @inline()
- implicit def enrichAsJavaIntToLongFunction[A0](sf: (A0) => Long)(implicit evA0: =:=[A0, Int]): RichFunction1AsIntToLongFunction
- Definition Classes
- Priority0FunctionExtensions
- Annotations
- @inline()
- implicit def enrichAsJavaIntUnaryOperator[A0](sf: (A0) => Int)(implicit evA0: =:=[A0, Int]): RichFunction1AsIntUnaryOperator
- Definition Classes
- Priority0FunctionExtensions
- Annotations
- @inline()
- implicit def enrichAsJavaLongBinaryOperator[A0, A1](sf: (A0, A1) => Long)(implicit evA0: =:=[A0, Long], evA1: =:=[A1, Long]): RichFunction2AsLongBinaryOperator
- Definition Classes
- Priority0FunctionExtensions
- Annotations
- @inline()
- implicit def enrichAsJavaLongConsumer[A0](sf: (A0) => Unit)(implicit evA0: =:=[A0, Long]): RichFunction1AsLongConsumer
- Definition Classes
- Priority0FunctionExtensions
- Annotations
- @inline()
- implicit def enrichAsJavaLongFunction[A0, R](sf: (A0) => R)(implicit evA0: =:=[A0, Long]): RichFunction1AsLongFunction[R]
- Definition Classes
- Priority1FunctionExtensions
- Annotations
- @inline()
- implicit def enrichAsJavaLongPredicate[A0](sf: (A0) => Boolean)(implicit evA0: =:=[A0, Long]): RichFunction1AsLongPredicate
- Definition Classes
- Priority0FunctionExtensions
- Annotations
- @inline()
- implicit def enrichAsJavaLongSupplier(sf: () => Long): RichFunction0AsLongSupplier
- Definition Classes
- Priority0FunctionExtensions
- Annotations
- @inline()
- implicit def enrichAsJavaLongToDoubleFunction[A0](sf: (A0) => Double)(implicit evA0: =:=[A0, Long]): RichFunction1AsLongToDoubleFunction
- Definition Classes
- Priority0FunctionExtensions
- Annotations
- @inline()
- implicit def enrichAsJavaLongToIntFunction[A0](sf: (A0) => Int)(implicit evA0: =:=[A0, Long]): RichFunction1AsLongToIntFunction
- Definition Classes
- Priority0FunctionExtensions
- Annotations
- @inline()
- implicit def enrichAsJavaLongUnaryOperator[A0](sf: (A0) => Long)(implicit evA0: =:=[A0, Long]): RichFunction1AsLongUnaryOperator
- Definition Classes
- Priority0FunctionExtensions
- Annotations
- @inline()
- implicit def enrichAsJavaObjDoubleConsumer[T, A1](sf: (T, A1) => Unit)(implicit evA1: =:=[A1, Double]): RichFunction2AsObjDoubleConsumer[T]
- Definition Classes
- Priority1FunctionExtensions
- Annotations
- @inline()
- implicit def enrichAsJavaObjIntConsumer[T, A1](sf: (T, A1) => Unit)(implicit evA1: =:=[A1, Int]): RichFunction2AsObjIntConsumer[T]
- Definition Classes
- Priority1FunctionExtensions
- Annotations
- @inline()
- implicit def enrichAsJavaObjLongConsumer[T, A1](sf: (T, A1) => Unit)(implicit evA1: =:=[A1, Long]): RichFunction2AsObjLongConsumer[T]
- Definition Classes
- Priority1FunctionExtensions
- Annotations
- @inline()
- implicit def enrichAsJavaPredicate[T](sf: (T) => Boolean): RichFunction1AsPredicate[T]
- Definition Classes
- Priority1FunctionExtensions
- Annotations
- @inline()
- implicit def enrichAsJavaSupplier[T](sf: () => T): RichFunction0AsSupplier[T]
- Definition Classes
- Priority1FunctionExtensions
- Annotations
- @inline()
- implicit def enrichAsJavaToDoubleBiFunction[T, U](sf: (T, U) => Double): RichFunction2AsToDoubleBiFunction[T, U]
- Definition Classes
- Priority2FunctionExtensions
- Annotations
- @inline()
- implicit def enrichAsJavaToDoubleFunction[T](sf: (T) => Double): RichFunction1AsToDoubleFunction[T]
- Definition Classes
- Priority1FunctionExtensions
- Annotations
- @inline()
- implicit def enrichAsJavaToIntBiFunction[T, U](sf: (T, U) => Int): RichFunction2AsToIntBiFunction[T, U]
- Definition Classes
- Priority2FunctionExtensions
- Annotations
- @inline()
- implicit def enrichAsJavaToIntFunction[T](sf: (T) => Int): RichFunction1AsToIntFunction[T]
- Definition Classes
- Priority1FunctionExtensions
- Annotations
- @inline()
- implicit def enrichAsJavaToLongBiFunction[T, U](sf: (T, U) => Long): RichFunction2AsToLongBiFunction[T, U]
- Definition Classes
- Priority2FunctionExtensions
- Annotations
- @inline()
- implicit def enrichAsJavaToLongFunction[T](sf: (T) => Long): RichFunction1AsToLongFunction[T]
- Definition Classes
- Priority1FunctionExtensions
- Annotations
- @inline()
- implicit def enrichAsJavaUnaryOperator[T, A1](sf: (T) => A1)(implicit evA1: =:=[A1, T]): RichFunction1AsUnaryOperator[T]
- Definition Classes
- Priority1FunctionExtensions
- Annotations
- @inline()
- implicit def enrichAsScalaFromBiConsumer[T, U](jf: BiConsumer[T, U]): RichBiConsumerAsFunction2[T, U]
- Definition Classes
- Priority0FunctionExtensions
- Annotations
- @inline()
- implicit def enrichAsScalaFromBiFunction[T, U, R](jf: BiFunction[T, U, R]): RichBiFunctionAsFunction2[T, U, R]
- Definition Classes
- Priority0FunctionExtensions
- Annotations
- @inline()
- implicit def enrichAsScalaFromBiPredicate[T, U](jf: BiPredicate[T, U]): RichBiPredicateAsFunction2[T, U]
- Definition Classes
- Priority0FunctionExtensions
- Annotations
- @inline()
- implicit def enrichAsScalaFromBinaryOperator[T](jf: BinaryOperator[T]): RichBinaryOperatorAsFunction2[T]
- Definition Classes
- Priority0FunctionExtensions
- Annotations
- @inline()
- implicit def enrichAsScalaFromBooleanSupplier(jf: BooleanSupplier): RichBooleanSupplierAsFunction0
- Definition Classes
- Priority0FunctionExtensions
- Annotations
- @inline()
- implicit def enrichAsScalaFromConsumer[T](jf: Consumer[T]): RichConsumerAsFunction1[T]
- Definition Classes
- Priority0FunctionExtensions
- Annotations
- @inline()
- implicit def enrichAsScalaFromDoubleBinaryOperator(jf: DoubleBinaryOperator): RichDoubleBinaryOperatorAsFunction2
- Definition Classes
- Priority0FunctionExtensions
- Annotations
- @inline()
- implicit def enrichAsScalaFromDoubleConsumer(jf: DoubleConsumer): RichDoubleConsumerAsFunction1
- Definition Classes
- Priority0FunctionExtensions
- Annotations
- @inline()
- implicit def enrichAsScalaFromDoubleFunction[R](jf: DoubleFunction[R]): RichDoubleFunctionAsFunction1[R]
- Definition Classes
- Priority0FunctionExtensions
- Annotations
- @inline()
- implicit def enrichAsScalaFromDoublePredicate(jf: DoublePredicate): RichDoublePredicateAsFunction1
- Definition Classes
- Priority0FunctionExtensions
- Annotations
- @inline()
- implicit def enrichAsScalaFromDoubleSupplier(jf: DoubleSupplier): RichDoubleSupplierAsFunction0
- Definition Classes
- Priority0FunctionExtensions
- Annotations
- @inline()
- implicit def enrichAsScalaFromDoubleToIntFunction(jf: DoubleToIntFunction): RichDoubleToIntFunctionAsFunction1
- Definition Classes
- Priority0FunctionExtensions
- Annotations
- @inline()
- implicit def enrichAsScalaFromDoubleToLongFunction(jf: DoubleToLongFunction): RichDoubleToLongFunctionAsFunction1
- Definition Classes
- Priority0FunctionExtensions
- Annotations
- @inline()
- implicit def enrichAsScalaFromDoubleUnaryOperator(jf: DoubleUnaryOperator): RichDoubleUnaryOperatorAsFunction1
- Definition Classes
- Priority0FunctionExtensions
- Annotations
- @inline()
- implicit def enrichAsScalaFromFunction[T, R](jf: java.util.function.Function[T, R]): RichFunctionAsFunction1[T, R]
- Definition Classes
- Priority0FunctionExtensions
- Annotations
- @inline()
- implicit def enrichAsScalaFromIntBinaryOperator(jf: IntBinaryOperator): RichIntBinaryOperatorAsFunction2
- Definition Classes
- Priority0FunctionExtensions
- Annotations
- @inline()
- implicit def enrichAsScalaFromIntConsumer(jf: IntConsumer): RichIntConsumerAsFunction1
- Definition Classes
- Priority0FunctionExtensions
- Annotations
- @inline()
- implicit def enrichAsScalaFromIntFunction[R](jf: IntFunction[R]): RichIntFunctionAsFunction1[R]
- Definition Classes
- Priority0FunctionExtensions
- Annotations
- @inline()
- implicit def enrichAsScalaFromIntPredicate(jf: IntPredicate): RichIntPredicateAsFunction1
- Definition Classes
- Priority0FunctionExtensions
- Annotations
- @inline()
- implicit def enrichAsScalaFromIntSupplier(jf: IntSupplier): RichIntSupplierAsFunction0
- Definition Classes
- Priority0FunctionExtensions
- Annotations
- @inline()
- implicit def enrichAsScalaFromIntToDoubleFunction(jf: IntToDoubleFunction): RichIntToDoubleFunctionAsFunction1
- Definition Classes
- Priority0FunctionExtensions
- Annotations
- @inline()
- implicit def enrichAsScalaFromIntToLongFunction(jf: IntToLongFunction): RichIntToLongFunctionAsFunction1
- Definition Classes
- Priority0FunctionExtensions
- Annotations
- @inline()
- implicit def enrichAsScalaFromIntUnaryOperator(jf: IntUnaryOperator): RichIntUnaryOperatorAsFunction1
- Definition Classes
- Priority0FunctionExtensions
- Annotations
- @inline()
- implicit def enrichAsScalaFromLongBinaryOperator(jf: LongBinaryOperator): RichLongBinaryOperatorAsFunction2
- Definition Classes
- Priority0FunctionExtensions
- Annotations
- @inline()
- implicit def enrichAsScalaFromLongConsumer(jf: LongConsumer): RichLongConsumerAsFunction1
- Definition Classes
- Priority0FunctionExtensions
- Annotations
- @inline()
- implicit def enrichAsScalaFromLongFunction[R](jf: LongFunction[R]): RichLongFunctionAsFunction1[R]
- Definition Classes
- Priority0FunctionExtensions
- Annotations
- @inline()
- implicit def enrichAsScalaFromLongPredicate(jf: LongPredicate): RichLongPredicateAsFunction1
- Definition Classes
- Priority0FunctionExtensions
- Annotations
- @inline()
- implicit def enrichAsScalaFromLongSupplier(jf: LongSupplier): RichLongSupplierAsFunction0
- Definition Classes
- Priority0FunctionExtensions
- Annotations
- @inline()
- implicit def enrichAsScalaFromLongToDoubleFunction(jf: LongToDoubleFunction): RichLongToDoubleFunctionAsFunction1
- Definition Classes
- Priority0FunctionExtensions
- Annotations
- @inline()
- implicit def enrichAsScalaFromLongToIntFunction(jf: LongToIntFunction): RichLongToIntFunctionAsFunction1
- Definition Classes
- Priority0FunctionExtensions
- Annotations
- @inline()
- implicit def enrichAsScalaFromLongUnaryOperator(jf: LongUnaryOperator): RichLongUnaryOperatorAsFunction1
- Definition Classes
- Priority0FunctionExtensions
- Annotations
- @inline()
- implicit def enrichAsScalaFromObjDoubleConsumer[T](jf: ObjDoubleConsumer[T]): RichObjDoubleConsumerAsFunction2[T]
- Definition Classes
- Priority0FunctionExtensions
- Annotations
- @inline()
- implicit def enrichAsScalaFromObjIntConsumer[T](jf: ObjIntConsumer[T]): RichObjIntConsumerAsFunction2[T]
- Definition Classes
- Priority0FunctionExtensions
- Annotations
- @inline()
- implicit def enrichAsScalaFromObjLongConsumer[T](jf: ObjLongConsumer[T]): RichObjLongConsumerAsFunction2[T]
- Definition Classes
- Priority0FunctionExtensions
- Annotations
- @inline()
- implicit def enrichAsScalaFromPredicate[T](jf: Predicate[T]): RichPredicateAsFunction1[T]
- Definition Classes
- Priority0FunctionExtensions
- Annotations
- @inline()
- implicit def enrichAsScalaFromSupplier[T](jf: Supplier[T]): RichSupplierAsFunction0[T]
- Definition Classes
- Priority0FunctionExtensions
- Annotations
- @inline()
- implicit def enrichAsScalaFromToDoubleBiFunction[T, U](jf: ToDoubleBiFunction[T, U]): RichToDoubleBiFunctionAsFunction2[T, U]
- Definition Classes
- Priority0FunctionExtensions
- Annotations
- @inline()
- implicit def enrichAsScalaFromToDoubleFunction[T](jf: ToDoubleFunction[T]): RichToDoubleFunctionAsFunction1[T]
- Definition Classes
- Priority0FunctionExtensions
- Annotations
- @inline()
- implicit def enrichAsScalaFromToIntBiFunction[T, U](jf: ToIntBiFunction[T, U]): RichToIntBiFunctionAsFunction2[T, U]
- Definition Classes
- Priority0FunctionExtensions
- Annotations
- @inline()
- implicit def enrichAsScalaFromToIntFunction[T](jf: ToIntFunction[T]): RichToIntFunctionAsFunction1[T]
- Definition Classes
- Priority0FunctionExtensions
- Annotations
- @inline()
- implicit def enrichAsScalaFromToLongBiFunction[T, U](jf: ToLongBiFunction[T, U]): RichToLongBiFunctionAsFunction2[T, U]
- Definition Classes
- Priority0FunctionExtensions
- Annotations
- @inline()
- implicit def enrichAsScalaFromToLongFunction[T](jf: ToLongFunction[T]): RichToLongFunctionAsFunction1[T]
- Definition Classes
- Priority0FunctionExtensions
- Annotations
- @inline()
- implicit def enrichAsScalaFromUnaryOperator[T](jf: UnaryOperator[T]): RichUnaryOperatorAsFunction1[T]
- Definition Classes
- Priority0FunctionExtensions
- Annotations
- @inline()
- final def eq(arg0: AnyRef): Boolean
Tests whether the argument (
that
) is a reference to the receiver object (this
).Tests whether the argument (
that
) is a reference to the receiver object (this
).The
eq
method implements an equivalence relation on non-null instances ofAnyRef
, and has three additional properties:- It is consistent: for any non-null instances
x
andy
of typeAnyRef
, multiple invocations ofx.eq(y)
consistently returnstrue
or consistently returnsfalse
. - For any non-null instance
x
of typeAnyRef
,x.eq(null)
andnull.eq(x)
returnsfalse
. null.eq(null)
returnstrue
.
When overriding the
equals
orhashCode
methods, it is important to ensure that their behavior is consistent with reference equality. Therefore, if two objects are references to each other (o1 eq o2
), they should be equal to each other (o1 == o2
) and they should hash to the same value (o1.hashCode == o2.hashCode
).- returns
true
if the argument is a reference to the receiver object;false
otherwise.
- Definition Classes
- AnyRef
- It is consistent: for any non-null instances
- def equals(arg0: AnyRef): Boolean
The equality method for reference types.
- def finalize(): Unit
Called by the garbage collector on the receiver object when there are no more references to the object.
Called by the garbage collector on the receiver object when there are no more references to the object.
The details of when and if the
finalize
method is invoked, as well as the interaction betweenfinalize
and non-local returns and exceptions, are all platform dependent.- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.Throwable])
- Note
not specified by SLS as a member of AnyRef
- final def getClass(): Class[_ <: AnyRef]
Returns the runtime class representation of the object.
- def hashCode(): Int
The hashCode method for reference types.
- final def isInstanceOf[T0]: Boolean
Test whether the dynamic type of the receiver object is
T0
.Test whether the dynamic type of the receiver object is
T0
.Note that the result of the test is modulo Scala's erasure semantics. Therefore the expression
1.isInstanceOf[String]
will returnfalse
, while the expressionList(1).isInstanceOf[List[String]]
will returntrue
. In the latter example, because the type argument is erased as part of compilation it is not possible to check whether the contents of the list are of the specified type.- returns
true
if the receiver object is an instance of erasure of typeT0
;false
otherwise.
- Definition Classes
- Any
- final def ne(arg0: AnyRef): Boolean
Equivalent to
!(this eq that)
.Equivalent to
!(this eq that)
.- returns
true
if the argument is not a reference to the receiver object;false
otherwise.
- Definition Classes
- AnyRef
- final def notify(): Unit
Wakes up a single thread that is waiting on the receiver object's monitor.
Wakes up a single thread that is waiting on the receiver object's monitor.
- Definition Classes
- AnyRef
- Annotations
- @native()
- Note
not specified by SLS as a member of AnyRef
- final def notifyAll(): Unit
Wakes up all threads that are waiting on the receiver object's monitor.
Wakes up all threads that are waiting on the receiver object's monitor.
- Definition Classes
- AnyRef
- Annotations
- @native()
- Note
not specified by SLS as a member of AnyRef
- final def synchronized[T0](arg0: => T0): T0
Executes the code in
body
with an exclusive lock onthis
.Executes the code in
body
with an exclusive lock onthis
.- returns
the result of
body
- Definition Classes
- AnyRef
- def toString(): String
Creates a String representation of this object.
Creates a String representation of this object. The default representation is platform dependent. On the java platform it is the concatenation of the class name, "@", and the object's hashcode in hexadecimal.
- returns
a String representation of the object.
- Definition Classes
- AnyRef → Any
- final def wait(): Unit
See https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#wait--.
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
- Note
not specified by SLS as a member of AnyRef
- final def wait(arg0: Long, arg1: Int): Unit
See https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#wait-long-int-
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
- Note
not specified by SLS as a member of AnyRef
- final def wait(arg0: Long): Unit
See https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#wait-long-.
This is the documentation for the Scala standard library.
Package structure
The scala package contains core types like
Int
,Float
,Array
orOption
which are accessible in all Scala compilation units without explicit qualification or imports.Notable packages include:
scala.collection
and its sub-packages contain Scala's collections frameworkscala.collection.immutable
- Immutable, sequential data-structures such asVector
,List
,Range
,HashMap
orHashSet
scala.collection.mutable
- Mutable, sequential data-structures such asArrayBuffer
,StringBuilder
,HashMap
orHashSet
scala.collection.concurrent
- Mutable, concurrent data-structures such asTrieMap
scala.concurrent
- Primitives for concurrent programming such asFutures
andPromises
scala.io
- Input and output operationsscala.math
- Basic math functions and additional numeric types likeBigInt
andBigDecimal
scala.sys
- Interaction with other processes and the operating systemscala.util.matching
- Regular expressionsOther packages exist. See the complete list on the right.
Additional parts of the standard library are shipped as separate libraries. These include:
scala.reflect
- Scala's reflection API (scala-reflect.jar)scala.xml
- XML parsing, manipulation, and serialization (scala-xml.jar)scala.collection.parallel
- Parallel collections (scala-parallel-collections.jar)scala.util.parsing
- Parser combinators (scala-parser-combinators.jar)scala.swing
- A convenient wrapper around Java's GUI framework called Swing (scala-swing.jar)Automatic imports
Identifiers in the scala package and the
scala.Predef
object are always in scope by default.Some of these identifiers are type aliases provided as shortcuts to commonly used classes. For example,
List
is an alias forscala.collection.immutable.List
.Other aliases refer to classes provided by the underlying platform. For example, on the JVM,
String
is an alias forjava.lang.String
.