beginning scala

The ‘using’ control structure in Beginning Scala (by David Pollak)

In David Pollak's book, Beginning Scala, he introduces a using control structure that is helpful in several ways. First, it can be used to automatically close any resource that has a close method. Second, it's a great example of how to create a custom control structure in Scala.

Introduction

Here's the source code for the using control structure he created:

Scala best practices: null values, Option, Some, and None

In his excellent book, Beginning Scala, David Pollak provides a series of statements that can be considered as a recipe for avoiding the use of null values in your Scala code. I've organized his statements here in the following three sections.

1) General rules about null and Option

We begin with the following general rules regarding the use of null values in Scala code:

Managing MongoDB connections with the Scala Casbah database driver

UPDATE: November 14, 2012. This article describes problems I had when attempting to use the Scala Casbah driver for the MongoDB database. In the end, it turned out I was doing something wrong. However, because this article shows how to troubleshoot MongoDB and Casbah database connection problems, it seems like a good idea to leave it here. If you want to see the correct way to use Casbah with MongoDB, I created this Github project, which shows the correct approach.