Blogs

Scala packaging and import examples

This article is a collection of Scala packaging and import examples. I created most of these examples when I was writing the Scala Cookbook. I share them here without much discussion, but for more examples and discussion, please check out the Cookbook.

Packages imported by default

By default, three packages are implicitly imported for you:

Scala object examples

This article is a collection of Scala “object” examples. I put the word object in quotes there because it has at least two meanings in Scala. In the first meaning, just like Java, an object is an instance of a class.

In its second meaning, Scala has an object keyword, and using that keyword lets you do a variety of things, including creating a main method to launch your application, to create the equivalent of Java’s static methods, and also to create something called a companion object.

Comparison of the 2015 Subaru Outback vs Forester

I recently went into a Subaru dealership to buy a 2015 Subaru Forester. I currently live in Colorado, and may move back to Alaska, so it’s important to me to have an all-wheel drive vehicle for either winter experience. Although I went into the dealership to buy a Forester, I ended up buying an Outback. As a result of that experience I thought I’d share what I learned about the two cars.

Scala method and function examples

This page contains a collection of Scala method examples. I created many of these examples while I was writing the Scala Cookbook. Unlike the Cookbook, where I explain these examples in great detail, on this page I’m just sharing many of the examples so you can use this as a method/function reference page. (The Cookbook contains more examples than this page, and explains them in detail.)

Scala trait examples

This page contains a collection of Scala trait examples. I created many of these examples when I was writing the Scala Cookbook. Unlike the Cookbook, where I explain these examples in great detail, on this page I’m just sharing many of the examples so you can use this as a trait reference page. (The Cookbook actually contains more examples than this page.)

Without any more introduction, here are the examples.

Syndicate content