Packages

  • package root

    This is the documentation for the Scala standard library.

    This is the documentation for the Scala standard library.

    Package structure

    The scala package contains core types like Int, Float, Array or Option which are accessible in all Scala compilation units without explicit qualification or imports.

    Notable packages include:

    Other packages exist. See the complete list on the right.

    Additional parts of the standard library are shipped as separate libraries. These include:

    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 for scala.collection.immutable.List.

    Other aliases refer to classes provided by the underlying platform. For example, on the JVM, String is an alias for java.lang.String.

    Definition Classes
    root
  • package scala

    Core Scala types.

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

    Definition Classes
    root
  • package concurrent

    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 at https://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 like Futures, it is often required to have an implicit ExecutionContext in scope. The general advice for these implicits are as follows.

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

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

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

    For typical REPL usage and experimentation, importing the global ExecutionContext 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 context
    
    val 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 - aardvark
    
    animalRange.onSuccess {
      case x if x > 500000 => println("It's a long way from Aardvark to Zebra")
    }
    Definition Classes
    scala
  • object Future

    Future companion object.

    Future companion object.

    Definition Classes
    concurrent
  • never

object never extends Future[Nothing]

A Future which is never completed.

Source
Future.scala
Linear Supertypes
Ordering
  1. Grouped
  2. Alphabetic
  3. By Inheritance
Inherited
  1. never
  2. Future
  3. Awaitable
  4. AnyRef
  5. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. Protected

Value Members

  1. 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
  2. final def ##: Int

    Equivalent to x.hashCode except for boxed numeric types and null.

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

    returns

    a hash value consistent with ==

    Definition Classes
    AnyRef → Any
  3. final def ==(arg0: Any): Boolean

    The expression x == that is equivalent to if (x eq null) that eq null else x.equals(that).

    The expression x == that is equivalent to if (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
  4. final 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 andThen callbacks throws an exception, that exception is not propagated to the subsequent andThen callbacks. Instead, the subsequent andThen callbacks are given the original value of this future.

    The following example prints out 5:

    val f = Future { 5 }
    f andThen {
      case r => throw new RuntimeException("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 PartialFunction which will be conditionally applied to the outcome of this Future

    returns

    a Future which will be completed with the exact same outcome as this Future but after the PartialFunction has been executed.

    Definition Classes
    neverFuture
  5. 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 a ClassCastException at runtime, while the expression List(1).asInstanceOf[List[String]] will not. In the latter example, because the type argument is erased as part of compilation it is not possible to check whether the contents of the list are of the requested type.

    returns

    the receiver object.

    Definition Classes
    Any
    Exceptions thrown

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

  6. 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.

    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.CloneNotSupportedException]) @native()
    Note

    not specified by SLS as a member of AnyRef

  7. final 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 PartialFunction to apply to the successful result of this Future

    returns

    a Future holding the result of application of the PartialFunction or a NoSuchElementException

    Definition Classes
    neverFuture
  8. 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 of AnyRef, and has three additional properties:

    • It is consistent: for any non-null instances x and y of type AnyRef, multiple invocations of x.eq(y) consistently returns true or consistently returns false.
    • For any non-null instance x of type AnyRef, x.eq(null) and null.eq(x) returns false.
    • null.eq(null) returns true.

    When overriding the equals or hashCode methods, it is important to ensure that their behavior is consistent with reference equality. Therefore, if two objects are references to each other (o1 eq o2), they should be equal to each other (o1 == o2) and they should hash to the same value (o1.hashCode == o2.hashCode).

    returns

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

    Definition Classes
    AnyRef
  9. def equals(arg0: AnyRef): Boolean

    The equality method for reference types.

    The equality method for reference types. Default implementation delegates to eq.

    See also equals in scala.Any.

    returns

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

    Definition Classes
    AnyRef → Any
  10. final def failed: Future[Throwable]

    The returned Future will be successfully completed with the Throwable of the original Future if the original Future fails.

    The returned Future will be successfully completed with the Throwable of the original Future if the original Future fails.

    If the original Future is successful, the returned Future is failed with a NoSuchElementException.

    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 - fatal errors are not contained within futures
    • InterruptedException - not contained within futures
    • all scala.util.control.ControlThrowable except NonLocalReturnControl - 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.

    Definition Classes
    neverFuture
  11. final 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 that future if that is 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 that future if that is 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 { throw new RuntimeException("failed") }
    val g = Future { 5 }
    val h = f fallbackTo g
    h foreach println // Eventually prints 5
    U

    the type of the other Future and the resulting Future

    that

    the Future whose result we want to use if this Future fails.

    returns

    a Future with the successful result of this or that Future or the failure of this Future if both fail

    Definition Classes
    neverFuture
  12. final 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 Future which will hold the successful result of this Future if it matches the predicate or a NoSuchElementException

    Definition Classes
    neverFuture
  13. 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 between finalize 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

  14. final 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 Future which will be completed with the result of the application of the function

    Definition Classes
    neverFuture
  15. final 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).

    Creates a new future with one level of nesting flattened, this method is equivalent to flatMap(identity).

    S

    the type of the returned Future

    Definition Classes
    neverFuture
  16. final 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 Future completes with a result, the return value of f will be discarded.

    Definition Classes
    neverFuture
  17. final def getClass(): Class[_ <: AnyRef]

    Returns the runtime class representation of the object.

    Returns the runtime class representation of the object.

    returns

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

    Definition Classes
    AnyRef → Any
    Annotations
    @native()
  18. def hashCode(): Int

    The hashCode method for reference types.

    The hashCode method for reference types. See hashCode in scala.Any.

    returns

    the hash code value for this object.

    Definition Classes
    AnyRef → Any
    Annotations
    @native()
  19. final def isCompleted: Boolean

    Returns whether the future had already been completed with a value or an exception.

    Returns whether the future had already been completed with a value or an exception.

    Note: using this method yields nondeterministic dataflow programs.

    returns

    true if the future was completed, false otherwise

    Definition Classes
    neverFuture
  20. 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 return false, while the expression List(1).isInstanceOf[List[String]] will return true. In the latter example, because the type argument is erased as part of compilation it is not possible to check whether the contents of the list are of the specified type.

    returns

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

    Definition Classes
    Any
  21. final 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 Future may expand to include a call to map and or flatMap and withFilter. 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 Future which will be completed with the result of the application of the function

    Definition Classes
    neverFuture
  22. final def mapTo[S](implicit tag: ClassTag[S]): Future[S]

    Creates a new Future[S] which is completed with this Future's result if that conforms to S's erased type or a ClassCastException otherwise.

    Creates a new Future[S] which is completed with this Future's result if that conforms to S's erased type or a ClassCastException otherwise.

    S

    the type of the returned Future

    tag

    the ClassTag which will be used to cast the result of this Future

    returns

    a Future holding the casted result of this Future or a ClassCastException otherwise

    Definition Classes
    neverFuture
  23. 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
  24. 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

  25. 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

  26. final 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 f will 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 the execute() method on the ExecutionContext will be called once per callback or that execute() will be called in the current thread. That is, the implementation may run multiple callbacks in a batch within a single execute() and it may run execute() 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 Future completes

    Definition Classes
    neverFuture
  27. final 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
    neverAwaitable
    Annotations
    @throws(cause = scala.this.throws.<init>$default$1[scala.concurrent.TimeoutException]) @throws(cause = scala.this.throws.<init>$default$1[InterruptedException])
    Exceptions thrown

    IllegalArgumentException if atMost is Duration.Undefined

    InterruptedException if the current thread is interrupted while waiting

    TimeoutException if after waiting for the specified time this Awaitable is still not ready

  28. final 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 PartialFunction to apply if this Future fails

    returns

    a Future with the successful value of this Future or the result of the PartialFunction

    Definition Classes
    neverFuture
  29. final 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 PartialFunction to apply if this Future fails

    returns

    a Future with the successful value of this Future or the outcome of the Future returned by the PartialFunction

    Definition Classes
    neverFuture
  30. final def result(atMost: Duration)(implicit permit: CanAwait): Nothing

    Await and return the result (of type T) of this Awaitable.

    Await and return the result (of type T) of this Awaitable.

    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 Awaitable is completed within the specific maximum wait time

    Definition Classes
    neverAwaitable
    Annotations
    @throws(cause = scala.this.throws.<init>$default$1[scala.concurrent.TimeoutException]) @throws(cause = scala.this.throws.<init>$default$1[InterruptedException])
    Exceptions thrown

    IllegalArgumentException if atMost is Duration.Undefined

    InterruptedException if the current thread is interrupted while waiting

    TimeoutException if after waiting for the specified time this Awaitable is still not ready

  31. final def synchronized[T0](arg0: => T0): T0

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

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

    returns

    the result of body

    Definition Classes
    AnyRef
  32. final 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
    never → AnyRef → Any
  33. final 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 Future that will be completed with the transformed value

    Definition Classes
    neverFuture
  34. final 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 Future that will be completed with the transformed value

    Definition Classes
    neverFuture
  35. final 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 Future that will be completed with the transformed value

    Definition Classes
    neverFuture
  36. final 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 be Some(Success(t)) if it contained a valid result, or Some(Failure(error)) if it contained an exception.

    returns

    None if the Future wasn't completed, Some if it was.

    Definition Classes
    neverFuture
  37. 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

  38. 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

  39. final def wait(arg0: Long): Unit

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

    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException]) @native()
    Note

    not specified by SLS as a member of AnyRef

  40. final def withFilter(p: (Nothing) => Boolean)(implicit executor: ExecutionContext): Future[Nothing]

    Used by for-comprehensions.

    Used by for-comprehensions.

    Definition Classes
    Future
  41. final def zip[U](that: Future[U]): Future[(Nothing, U)]

    Zips the values of this and that future, and creates a new future holding the tuple of their results.

    Zips the values of this and that future, and creates a new future holding the tuple of their results.

    If this future fails, the resulting future is failed with the throwable stored in this. Otherwise, if that future fails, the resulting future is failed with the throwable stored in that.

    U

    the type of the other Future

    that

    the other Future

    returns

    a Future with the results of both futures or the failure of the first of them that failed

    Definition Classes
    neverFuture
  42. final def zipWith[U, R](that: Future[U])(f: (Nothing, U) => R)(implicit executor: ExecutionContext): Future[R]

    Zips the values of this and that future using a function f, and creates a new future holding the result.

    Zips the values of this and that future using a function f, and creates a new future holding the result.

    If this future fails, the resulting future is failed with the throwable stored in this. Otherwise, if that future fails, the resulting future is failed with the throwable stored in that. If the application of f throws 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 this and that

    returns

    a Future with the result of the application of f to the results of this and that

    Definition Classes
    neverFuture

Inherited from Future[Nothing]

Inherited from Awaitable[Nothing]

Inherited from AnyRef

Inherited from Any

Callbacks

Polling

Transformations

Ungrouped