O'Reilly logo

Pragmatic Scala by Venkat Subramaniam

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Scala Surprises for the Java Eyes

As you start to appreciate Scala’s design elegance and conciseness, you should be aware of some nuances—for example, Scala differs semantically from Java in the way it handles assignment, equality check, and return from functions. Since the way these are handled is a significant departure from what we’re used to in Java, it’s easy to make mistakes. Take the time to learn these to avoid surprises.

Result of Assignment

In Java, the result of the assignment operation, like a = b, is the value of a, so multiple assignments like x = a = b; can appear in series, but not so in Scala. The result of assignment operation in Scala is a Unit—a rough equivalent of Void. As a consequence, assigning that result to another ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required