How to write a Scala method (function) that returns a Future

As a quick note, if you need to see how to write a Scala method that returns a Future, this example may help:

def slowlyDouble(x: Int, delay: Int): Future[Int] = Future {
    x * 2

I’m not going to write about this in detail here because I discuss it in my How to use multiple Scala Futures in a for-comprehension tutorial, so please see that link for more information.

Share it!

There’s just one person behind this website; if this article was helpful (or interesting), I’d appreciate it if you’d share it. Thanks, Al.

Add new comment

The content of this field is kept private and will not be shown publicly.

Anonymous format

  • Allowed HTML tags: <em> <strong> <cite> <code> <ul type> <ol start type> <li> <pre>
  • Lines and paragraphs break automatically.
By submitting this form, you accept the Mollom privacy policy.