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:
- 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"
- Create a Scala App:
object ScalaFutureHelloWorldApp extends App{ }
- Create a HelloWorld Future Object:
ScalaFutureHelloWorldApp.scala:
import scala.concurrent.Future object ScalaFutureHelloWorldApp extends App{ val helloWordlFuture = Future("Hello World") }
- 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: ...