O'Reilly logo

Scala Reactive Programming by Rambabu Posa

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Scala Future examples

We have discussed lots of theory so far. It's good to start developing some examples to understand the Scala Future API. Let's start now with the Scala Hello World Future App:

  1. Create a Scala SBT project in your favorite IDE (mine is IntelliJ IDEA):
      Project Name: scala-future-app

build.sbt:

      name := "scala-future-app" 
      version := "1.0" 
      scalaVersion := "2.12.3" 
  1. Create a Scala App:
      object ScalaFutureHelloWorldApp extends App{      }
  1. Create a HelloWorld Future Object:

ScalaFutureHelloWorldApp.scala:

      import scala.concurrent.Future      object ScalaFutureHelloWorldApp extends App{        val helloWordlFuture = Future("Hello World")      }
  1. When we run this program, we can observe the following error:
[error] .../scala-future- app/src/main/scala/com/packt/publishing/concurrent/future/ScalaFutureHelloWolrdApp.scala:8: ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required