Scala Language Creating a Future


Example

import scala.concurrent.Future
import scala.concurrent.ExecutionContext.Implicits.global

object FutureDivider {
    def divide(a: Int, b: Int): Future[Int] = Future {
        // Note that this is integer division.
        a / b
    }
}

Quite simply, the divide method creates a Future that will resolve with the quotient of a over b.