var

How to access Scala var and val fields from Java

I just ran into one thing I wish I had included in the Scala Cookbook that I didn’t include: How to access a val or var field in a Scala object from your Java code.

In short, if you have a field named appName defined in a Scala object, like this:

Scala - How to declare multiple variables on one line

I thought I’d have a little fun with Scala today, and show different ways to declare multiple variables on one line. These aren’t the most useful or common things to do, but they’re interesting, and I know I learned at least one thing while looking into this.

You can define multiple fields on one line, separated by commas, as long as they are all the same type and have the same value:

A short video introduction to the Scala REPL and variables

I didn't feel like going out in the rain and snow yesterday here in the Boulder, Colorado area, so I decided to stay indoors and create a video introduction to the Scala REPL and the Scala variable types, var and val. Without any further ado, here's the video: