A fun thing you can do with the map method on Scala sequences (Array, List, Seq, Vector, etc.), is convert a sequence of objects into a sequence of something else, typically extracting a field from the original object to create the new sequence.
For instance, imagine that you have a case class named Person that has two constructor parameters, firstName and lastName:
This is a short example of how to create a Play FrameworkController method that returns JSON. I’ve written this brief tutorial assuming you already know the basics of Play, i.e., what a Controller is, where the routes file, and how to run Play.
As you’ll see, it’s pretty simple. (Or, as a friend says, “It’s obvious ... once you know how to do it.”)
There are a number of ways to work with Scala Futures, and I provide examples of those approaches in the Scala Cookbook.
If you’re new to Futures, a fun exercise is to try to determine what happens in your code when you use a certain technique. For instance, when you look at the following Scala source code, what do you think it will print?
I like to set the title (titlebar) on the Mac OS X Terminal application so I can tell one tab from another. For instance, I may have the Play Framework running in one tab, SBT in another, Git in another, etc. Setting the title on each Terminal tab makes my life a little easier.
To set the Terminal title, I use a script I’ve named settitle: