object never extends Future[Nothing]
- Grouped
- Alphabetic
- By Inheritance
- never
- Future
- Awaitable
- AnyRef
- Any
- Hide All
- Show All
- Public
- All
Value Members
-
final
def
!=(arg0: Any): Boolean
Test two objects for inequality.
Test two objects for inequality.
- returns
trueif !(this == that), false otherwise.
- Definition Classes
- AnyRef → Any
-
final
def
##(): Int
Equivalent to
x.hashCodeexcept for boxed numeric types andnull.Equivalent to
x.hashCodeexcept 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. Fornullreturns a hashcode wherenull.hashCodethrows aNullPointerException.- returns
a hash value consistent with ==
- Definition Classes
- AnyRef → Any
-
final
def
==(arg0: Any): Boolean
The expression
x == thatis equivalent toif (x eq null) that eq null else x.equals(that).The expression
x == thatis equivalent toif (x eq null) that eq null else x.equals(that).- returns
trueif the receiver object is equivalent to the argument;falseotherwise.
- Definition Classes
- AnyRef → Any
-
def
andThen[U](pf: PartialFunction[Try[Nothing], U])(implicit executor: ExecutionContext): Future[Nothing]
Applies the side-effecting function to the result of this future, and returns a new future with the result of this future.
Applies the side-effecting function to the result of this future, and returns a new future with the result of this future.
This method allows one to enforce that the callbacks are executed in a specified order.
Note that if one of the chained
andThencallbacks throws an exception, that exception is not propagated to the subsequentandThencallbacks. Instead, the subsequentandThencallbacks are given the original value of this future.The following example prints out
5:val f = Future { 5 } f andThen { case r => sys.error("runtime exception") } andThen { case Failure(t) => println(t) case Success(v) => println(v) }
Since this method executes asynchronously and does not produce a return value, any non-fatal exceptions thrown will be reported to the
ExecutionContext.- U
only used to accept any return type of the given
PartialFunction- pf
a
PartialFunctionwhich will be conditionally applied to the outcome of thisFuture- returns
a
Futurewhich will be completed with the exact same outcome as thisFuturebut after thePartialFunctionhas been executed.
-
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 aClassCastExceptionat 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
ClassCastExceptionif the receiver object is not an instance of the erasure of typeT0.
-
def
clone(): AnyRef
Create a copy of the receiver object.
-
def
collect[S](pf: PartialFunction[Nothing, S])(implicit executor: ExecutionContext): Future[S]
Creates a new future by mapping the value of the current future, if the given partial function is defined at that value.
Creates a new future by mapping the value of the current future, if the given partial function is defined at that value.
If the current future contains a value for which the partial function is defined, the new future will also hold that value. Otherwise, the resulting future will fail with a
NoSuchElementException.If the current future fails, then the resulting future also fails.
Example:
val f = Future { -5 } val g = f collect { case x if x < 0 => -x } val h = f collect { case x if x > 0 => x * 2 } g foreach println // Eventually prints 5 Await.result(h, Duration.Zero) // throw a NoSuchElementException
- S
the type of the returned
Future- pf
the
PartialFunctionto apply to the successful result of thisFuture- returns
a
Futureholding the result of application of thePartialFunctionor aNoSuchElementException
-
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
eqmethod implements an equivalence relation on non-null instances ofAnyRef, and has three additional properties:- It is consistent: for any non-null instances
xandyof typeAnyRef, multiple invocations ofx.eq(y)consistently returnstrueor consistently returnsfalse. - For any non-null instance
xof typeAnyRef,x.eq(null)andnull.eq(x)returnsfalse. null.eq(null)returnstrue.
When overriding the
equalsorhashCodemethods, 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
trueif the argument is a reference to the receiver object;falseotherwise.
- Definition Classes
- AnyRef
- It is consistent: for any non-null instances
-
def
equals(arg0: Any): Boolean
The equality method for reference types.
-
def
failed: Future[Throwable]
The returned
Futurewill be successfully completed with theThrowableof the originalFutureif the originalFuturefails.The returned
Futurewill be successfully completed with theThrowableof the originalFutureif the originalFuturefails.If the original
Futureis successful, the returnedFutureis failed with aNoSuchElementException.This future may contain a throwable object and this means that the future failed. Futures obtained through combinators have the same exception as the future they were obtained from. The following throwable objects are not contained in the future:
Error- errors are not contained within futuresInterruptedException- not contained within futures- all
scala.util.control.ControlThrowableexceptNonLocalReturnControl- not contained within futures
Instead, the future is completed with a ExecutionException with one of the exceptions above as the cause. If a future is failed with a
scala.runtime.NonLocalReturnControl, it is completed with a value from that throwable instead.- returns
a failed projection of this
Future.
-
def
fallbackTo[U](that: Future[U]): Future[U]
Creates a new future which holds the result of this future if it was completed successfully, or, if not, the result of the
thatfuture ifthatis completed successfully.Creates a new future which holds the result of this future if it was completed successfully, or, if not, the result of the
thatfuture ifthatis completed successfully. If both futures are failed, the resulting future holds the throwable object of the first future.Using this method will not cause concurrent programs to become nondeterministic.
Example:
val f = Future { sys.error("failed") } val g = Future { 5 } val h = f fallbackTo g h foreach println // Eventually prints 5
- U
the type of the other
Futureand the resultingFuture- that
the
Futurewhose result we want to use if thisFuturefails.- returns
a
Futurewith the successful result of this or thatFutureor the failure of thisFutureif both fail
-
def
filter(p: (Nothing) ⇒ Boolean)(implicit executor: ExecutionContext): Future[Nothing]
Creates a new future by filtering the value of the current future with a predicate.
Creates a new future by filtering the value of the current future with a predicate.
If the current future contains a value which satisfies the predicate, the new future will also hold that value. Otherwise, the resulting future will fail with a
NoSuchElementException.If the current future fails, then the resulting future also fails.
Example:
val f = Future { 5 } val g = f filter { _ % 2 == 1 } val h = f filter { _ % 2 == 0 } g foreach println // Eventually prints 5 Await.result(h, Duration.Zero) // throw a NoSuchElementException
- p
the predicate to apply to the successful result of this
Future- returns
a
Futurewhich will hold the successful result of thisFutureif it matches the predicate or aNoSuchElementException
-
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
finalizemethod is invoked, as well as the interaction betweenfinalizeand 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
-
def
flatMap[S](f: (Nothing) ⇒ Future[S])(implicit executor: ExecutionContext): Future[S]
Creates a new future by applying a function to the successful result of this future, and returns the result of the function as the new future.
Creates a new future by applying a function to the successful result of this future, and returns the result of the function as the new future. If this future is completed with an exception then the new future will also contain this exception.
Example:
val f = Future { 5 } val g = Future { 3 } val h = for { x: Int <- f // returns Future(5) y: Int <- g // returns Future(3) } yield x + y
is translated to:
f flatMap { (x: Int) => g map { (y: Int) => x + y } }- S
the type of the returned
Future- f
the function which will be applied to the successful result of this
Future- returns
a
Futurewhich will be completed with the result of the application of the function
-
def
flatten[S](implicit ev: <:<[Nothing, Future[S]]): Future[S]
Creates a new future with one level of nesting flattened, this method is equivalent to
flatMap(identity). -
def
foreach[U](f: (Nothing) ⇒ U)(implicit executor: ExecutionContext): Unit
Asynchronously processes the value in the future once the value becomes available.
Asynchronously processes the value in the future once the value becomes available.
WARNING: Will not be called if this future is never completed or if it is completed with a failure.
Since this method executes asynchronously and does not produce a return value, any non-fatal exceptions thrown will be reported to the
ExecutionContext.- U
only used to accept any return type of the given callback function
- f
the function which will be executed if this
Futurecompletes with a result, the return value offwill be discarded.
-
final
def
getClass(): Class[_]
Returns the runtime class representation of the object.
-
def
hashCode(): Int
The hashCode method for reference types.
-
def
isCompleted: Boolean
Returns whether the future had already been completed with a value or an exception.
-
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
trueif the receiver object is an instance of erasure of typeT0;falseotherwise.
- Definition Classes
- Any
-
def
map[S](f: (Nothing) ⇒ S)(implicit executor: ExecutionContext): Future[S]
Creates a new future by applying a function to the successful result of this future.
Creates a new future by applying a function to the successful result of this future. If this future is completed with an exception then the new future will also contain this exception.
Example:
val f = Future { "The future" } val g = f map { x: String => x + " is now!" }
Note that a for comprehension involving a
Futuremay expand to include a call tomapand orflatMapandwithFilter. See scala.concurrent.Future#flatMap for an example of such a comprehension.- S
the type of the returned
Future- f
the function which will be applied to the successful result of this
Future- returns
a
Futurewhich will be completed with the result of the application of the function
-
def
mapTo[S](implicit tag: ClassTag[S]): Future[S]
Creates a new
Future[S]which is completed with thisFuture's result if that conforms toS's erased type or aClassCastExceptionotherwise.Creates a new
Future[S]which is completed with thisFuture's result if that conforms toS's erased type or aClassCastExceptionotherwise.- S
the type of the returned
Future- tag
the
ClassTagwhich will be used to cast the result of thisFuture- returns
a
Futureholding the casted result of thisFutureor aClassCastExceptionotherwise
-
final
def
ne(arg0: AnyRef): Boolean
Equivalent to
!(this eq that).Equivalent to
!(this eq that).- returns
trueif the argument is not a reference to the receiver object;falseotherwise.
- 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
-
def
onComplete[U](f: (Try[Nothing]) ⇒ U)(implicit executor: ExecutionContext): Unit
When this future is completed, either through an exception, or a value, apply the provided function.
When this future is completed, either through an exception, or a value, apply the provided function.
If the future has already been completed, this will either be applied immediately or be scheduled asynchronously.
Note that the returned value of
fwill be discarded.Since this method executes asynchronously and does not produce a return value, any non-fatal exceptions thrown will be reported to the
ExecutionContext.Multiple callbacks may be registered; there is no guarantee that they will be executed in a particular order.
The provided callback always runs in the provided implicit
ExecutionContext, though there is no guarantee that theexecute()method on theExecutionContextwill be called once per callback or thatexecute()will be called in the current thread. That is, the implementation may run multiple callbacks in a batch within a singleexecute()and it may runexecute()either immediately or asynchronously. Completion of the Future must *happen-before* the invocation of the callback.- U
only used to accept any return type of the given callback function
- f
the function to be executed when this
Futurecompletes
-
def
onFailure[U](pf: PartialFunction[Throwable, U])(implicit executor: ExecutionContext): Unit
When this future is completed with a failure (i.e., with a throwable), apply the provided callback to the throwable.
When this future is completed with a failure (i.e., with a throwable), apply the provided callback to the throwable.
This future may contain a throwable object and this means that the future failed. Futures obtained through combinators have the same exception as the future they were obtained from. The following throwable objects are not contained in the future:
Error- errors are not contained within futuresInterruptedException- not contained within futures- all
scala.util.control.ControlThrowableexceptNonLocalReturnControl- not contained within futures
Instead, the future is completed with a ExecutionException with one of the exceptions above as the cause. If a future is failed with a
scala.runtime.NonLocalReturnControl, it is completed with a value from that throwable instead.If the future has already been completed with a failure, this will either be applied immediately or be scheduled asynchronously.
Will not be called in case that the future is completed with a value.
Note that the returned value of
pfwill be discarded.Since this method executes asynchronously and does not produce a return value, any non-fatal exceptions thrown will be reported to the
ExecutionContext.Multiple callbacks may be registered; there is no guarantee that they will be executed in a particular order.
The provided callback always runs in the provided implicit
ExecutionContext, though there is no guarantee that theexecute()method on theExecutionContextwill be called once per callback or thatexecute()will be called in the current thread. That is, the implementation may run multiple callbacks in a batch within a singleexecute()and it may runexecute()either immediately or asynchronously. Completion of the Future must *happen-before* the invocation of the callback. -
def
onSuccess[U](pf: PartialFunction[Nothing, U])(implicit executor: ExecutionContext): Unit
When this future is completed successfully (i.e., with a value), apply the provided partial function to the value if the partial function is defined at that value.
When this future is completed successfully (i.e., with a value), apply the provided partial function to the value if the partial function is defined at that value.
If the future has already been completed with a value, this will either be applied immediately or be scheduled asynchronously.
Note that the returned value of
pfwill be discarded.Since this method executes asynchronously and does not produce a return value, any non-fatal exceptions thrown will be reported to the
ExecutionContext.Multiple callbacks may be registered; there is no guarantee that they will be executed in a particular order.
The provided callback always runs in the provided implicit
ExecutionContext, though there is no guarantee that theexecute()method on theExecutionContextwill be called once per callback or thatexecute()will be called in the current thread. That is, the implementation may run multiple callbacks in a batch within a singleexecute()and it may runexecute()either immediately or asynchronously. Completion of the Future must *happen-before* the invocation of the callback. -
def
ready(atMost: Duration)(implicit permit: CanAwait): never.this.type
Await the "completed" state of this
Awaitable.Await the "completed" state of this
Awaitable.This method should not be called directly; use Await.ready instead.
- atMost
maximum wait time, which may be negative (no waiting is done), Duration.Inf for unbounded waiting, or a finite positive duration
- returns
this
Awaitable
- Definition Classes
- never → Awaitable
- Annotations
- @throws( clazz = classOf[TimeoutException] ) @throws( clazz = classOf[InterruptedException] )
- Exceptions thrown
IllegalArgumentExceptionifatMostis Duration.UndefinedInterruptedExceptionif the current thread is interrupted while waitingTimeoutExceptionif after waiting for the specified time thisAwaitableis still not ready
-
def
recover[U](pf: PartialFunction[Throwable, U])(implicit executor: ExecutionContext): Future[U]
Creates a new future that will handle any matching throwable that this future might contain.
Creates a new future that will handle any matching throwable that this future might contain. If there is no match, or if this future contains a valid result then the new future will contain the same.
Example:
Future (6 / 0) recover { case e: ArithmeticException => 0 } // result: 0 Future (6 / 0) recover { case e: NotFoundException => 0 } // result: exception Future (6 / 2) recover { case e: ArithmeticException => 0 } // result: 3
- U
the type of the returned
Future- pf
the
PartialFunctionto apply if thisFuturefails- returns
a
Futurewith the successful value of thisFutureor the result of thePartialFunction
-
def
recoverWith[U](pf: PartialFunction[Throwable, Future[U]])(implicit executor: ExecutionContext): Future[U]
Creates a new future that will handle any matching throwable that this future might contain by assigning it a value of another future.
Creates a new future that will handle any matching throwable that this future might contain by assigning it a value of another future.
If there is no match, or if this future contains a valid result then the new future will contain the same result.
Example:
val f = Future { Int.MaxValue } Future (6 / 0) recoverWith { case e: ArithmeticException => f } // result: Int.MaxValue
- U
the type of the returned
Future- pf
the
PartialFunctionto apply if thisFuturefails- returns
a
Futurewith the successful value of thisFutureor the outcome of theFuturereturned by thePartialFunction
-
def
result(atMost: Duration)(implicit permit: CanAwait): Nothing
Await and return the result (of type
T) of thisAwaitable.Await and return the result (of type
T) of thisAwaitable.This method should not be called directly; use Await.result instead.
- atMost
maximum wait time, which may be negative (no waiting is done), Duration.Inf for unbounded waiting, or a finite positive duration
- returns
the result value if the
Awaitableis completed within the specific maximum wait time
- Definition Classes
- never → Awaitable
- Annotations
- @throws( clazz = classOf[TimeoutException] ) @throws( clazz = classOf[InterruptedException] )
- Exceptions thrown
IllegalArgumentExceptionifatMostis Duration.UndefinedInterruptedExceptionif the current thread is interrupted while waitingTimeoutExceptionif after waiting for the specified time thisAwaitableis still not ready
-
final
def
synchronized[T0](arg0: ⇒ T0): T0
- Definition Classes
- AnyRef
-
def
toString(): String
Creates a String representation of this object.
-
def
transform[S](f: (Try[Nothing]) ⇒ Try[S])(implicit executor: ExecutionContext): Future[S]
Creates a new Future by applying the specified function to the result of this Future.
Creates a new Future by applying the specified function to the result of this Future. If there is any non-fatal exception thrown when 'f' is applied then that exception will be propagated to the resulting future.
- S
the type of the returned
Future- f
function that transforms the result of this future
- returns
a
Futurethat will be completed with the transformed value
-
def
transform[S](s: (Nothing) ⇒ S, f: (Throwable) ⇒ Throwable)(implicit executor: ExecutionContext): Future[S]
Creates a new future by applying the 's' function to the successful result of this future, or the 'f' function to the failed result.
Creates a new future by applying the 's' function to the successful result of this future, or the 'f' function to the failed result. If there is any non-fatal exception thrown when 's' or 'f' is applied, that exception will be propagated to the resulting future.
- S
the type of the returned
Future- s
function that transforms a successful result of the receiver into a successful result of the returned future
- f
function that transforms a failure of the receiver into a failure of the returned future
- returns
a
Futurethat will be completed with the transformed value
-
def
transformWith[S](f: (Try[Nothing]) ⇒ Future[S])(implicit executor: ExecutionContext): Future[S]
Creates a new Future by applying the specified function, which produces a Future, to the result of this Future.
Creates a new Future by applying the specified function, which produces a Future, to the result of this Future. If there is any non-fatal exception thrown when 'f' is applied then that exception will be propagated to the resulting future.
- S
the type of the returned
Future- f
function that transforms the result of this future
- returns
a
Futurethat will be completed with the transformed value
-
def
value: Option[Try[Nothing]]
The current value of this
Future.The current value of this
Future.Note: using this method yields nondeterministic dataflow programs.
If the future was not completed the returned value will be
None. If the future was completed the value will beSome(Success(t))if it contained a valid result, orSome(Failure(error))if it contained an exception.- returns
Noneif theFuturewasn't completed,Someif it was.
-
final
def
wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
- final def wait(arg0: Long): Unit
-
final
def
withFilter(p: (Nothing) ⇒ Boolean)(implicit executor: ExecutionContext): Future[Nothing]
Used by for-comprehensions.
Used by for-comprehensions.
- Definition Classes
- Future
-
def
zip[U](that: Future[U]): Future[(Nothing, U)]
Zips the values of
thisandthatfuture, and creates a new future holding the tuple of their results.Zips the values of
thisandthatfuture, and creates a new future holding the tuple of their results.If
thisfuture fails, the resulting future is failed with the throwable stored inthis. Otherwise, ifthatfuture fails, the resulting future is failed with the throwable stored inthat.- U
the type of the other
Future- that
the other
Future- returns
a
Futurewith the results of both futures or the failure of the first of them that failed
-
def
zipWith[U, R](that: Future[U])(f: (Nothing, U) ⇒ R)(implicit executor: ExecutionContext): Future[R]
Zips the values of
thisandthatfuture using a functionf, and creates a new future holding the result.Zips the values of
thisandthatfuture using a functionf, and creates a new future holding the result.If
thisfuture fails, the resulting future is failed with the throwable stored inthis. Otherwise, ifthatfuture fails, the resulting future is failed with the throwable stored inthat. If the application offthrows a throwable, the resulting future is failed with that throwable if it is non-fatal.- U
the type of the other
Future- R
the type of the resulting
Future- that
the other
Future- f
the function to apply to the results of
thisandthat- returns
a
Futurewith the result of the application offto the results ofthisandthat
This is the documentation for the Scala standard library.
Package structure
The scala package contains core types like
Int,Float,ArrayorOptionwhich are accessible in all Scala compilation units without explicit qualification or imports.Notable packages include:
scala.collectionand its sub-packages contain Scala's collections frameworkscala.collection.immutable- Immutable, sequential data-structures such asVector,List,Range,HashMaporHashSetscala.collection.mutable- Mutable, sequential data-structures such asArrayBuffer,StringBuilder,HashMaporHashSetscala.collection.concurrent- Mutable, concurrent data-structures such asTrieMapscala.collection.parallel.immutable- Immutable, parallel data-structures such asParVector,ParRange,ParHashMaporParHashSetscala.collection.parallel.mutable- Mutable, parallel data-structures such asParArray,ParHashMap,ParTrieMaporParHashSetscala.concurrent- Primitives for concurrent programming such asFuturesandPromisesscala.io- Input and output operationsscala.math- Basic math functions and additional numeric types likeBigIntandBigDecimalscala.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.swing- A convenient wrapper around Java's GUI framework called Swing (scala-swing.jar)scala.util.parsing- Parser combinators (scala-parser-combinators.jar)Automatic imports
Identifiers in the scala package and the
scala.Predefobject are always in scope by default.Some of these identifiers are type aliases provided as shortcuts to commonly used classes. For example,
Listis an alias forscala.collection.immutable.List.Other aliases refer to classes provided by the underlying platform. For example, on the JVM,
Stringis an alias forjava.lang.String.