I’m working on a little app for my Scala & functional programming book I currently call “Future Board.” It works a little like Flipboard in getting news headlines from different sources, but it uses Scala Futures and a few other functional programming techniques.
Here’s a little example of how exceptions work with Scala Futures, specifically looking at the
onComplete ‘Failure’ case.
In this example I start three Futures that run for different lengths of time, and the shortest-running
Future throws an exception:
This is a good article that shows several different ways to handle background tasks in Android, including
- Java threads
- Android HandlerThread
- Java Timer
The image is from an article titled, Why I don’t regret moving our Android app to Scala.
As I’m writing my new book on functional programming in Scala I started thinking, “What if the person who creates Skynet or the Matrix reads this book and suddenly understands how to create their evil invention? But ... if I don’t create this book, they’ll stay on their previous course in life to be a world-famous cookie baker.”
It’s quite a responsibility, knowing that you could be responsible for a future without great cookies.
Via a friend on Facebook:
“My advice: Don’t let yesterday contain the greatest things you’ve ever done. Make tomorrow contain your next great goal. Because once you feel your greatest days are behind you, you begin to die.”
At the very least that quote is about the importance of having goals.
“If you think you know what the state of the payments system 10 years out you're in a state of delusion.”
~ Charlie Munger talking about AMEX
Table of Contents
Besides having a bad memory, I haven’t been able to work with Scala much recently, so I’ve been putting together this list of
for loop examples.
This page is a work in progress, and as of tonight I haven’t tested some of the examples, but ... if you’re looking for some Scala
for loop examples — technically called a for-comprehension or for-expression — I hope these examples are helpful.
Viktor Klang has a series of blog posts about Futures in Scala 2.12.