scala

Tutorials about the Scala programming language.

Some Scala Exception allCatch examples

At the time of this writing there aren’t many examples of the Scala Exception object allCatch method to be found, so I thought I’d share some examples here.

In each example I first show the "success" case, and then show the "failure" case. Other than that, I won’t explain these, but hopefully seeing them in the REPL will be enough to get you pointed in the right direction:

How to declare, set, and use Option, Some, and None fields in Scala

Again not much time for a discussion today, but if you’re looking for an example of how to declare, set, and use Option fields in Scala, I hope this source code is helpful:

A simple Scala Try, Success, Failure example (reading a file)

Sorry, not much free time these days, so without any discussion, here’s a simple Scala Try/Success/Failure example:

Scala REPL - There were deprecation warnings, re-run with -deprecation

Whenever I used to get the Scala REPL warning message, "There were deprecation warnings, re-run with -deprecation", I used to have to restart the REPL with the -deprecation flag to see the warning message, like this:

$ scala -deprecation

That works, but sadly, you had to lose your entire REPL session to run it.

Use :warnings

Thanks to the Scala gods, this is no longer necessary in Scala 2.10 (and newer). Now, when you get the REPL deprecation warning message, like this:

Solution to the Scala jar class file is broken error

I just ran into the following Scala jar (class) is broken error:

A Scala XML NodeBuffer example

Here's a short example of how to use the Scala XML NodeBuffer class:

Learning how to write a technology book (for O'Reilly)

A fun part of writing the Scala Cookbook has been learning more about the process of thorough writing, and doing more research about topics than I've ever done before.

The process goes something like this: For the next 24 hours I'm working on editing the “XML & XPath” chapter, which was originally written a few months ago. For these 24 hours, I let myself “love” processing XML with Scala.

Scala tuple examples and syntax

Scala FAQ: Can you share some examples of using tuples in Scala?

A Scala tuple is a class that can contain a miscellaneous collection of elements. I like to think of them as a little bag or container you can use to hold things and pass them around.

You create a tuple with the following syntax, enclosing its elements in parentheses. Here's a tuple that contains an Int and a String:

A 'Ping Pong' Scala Akka actors example

Akka actors FAQ: Can you share an "Akka Actors 101" example (a simple "Introduction to Akka Actors" example)?

Sure. If you're looking for a really simple tutorial, check out my Akka Actors "Hello, world" tutorial. If that one is overly simplified and you want something more, continue on here.

Who's using Scala? (March, 2013)

Who's using Scala? With the recent blog post by LinkedIn (LinkedIn is using the Play Framework), showing that they're using the Play Framework, I thought I'd take a quick look at who we know is using Scala these days.

According to the Scala in the Enterprise page (and general knowledge), the following companies are using Scala:

Syndicate content