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

Chapter 4Working with Objects

Scala is fully object-oriented and provides concise syntax for creating classes and working with objects. You can achieve everything that’s possible in Java, and in addition, Scala provides some more powerful features to help with OO programming. Also, even though Scala is a pure object-oriented language, it still has to support Java’s not-so-pure OO concepts like static methods. Scala tackles that in a fairly interesting way using companion objects. Companion objects are singletons that accompany a class and are quite common in Scala.

We’re going to start on familiar ground and quickly dive into the OO aspects of Scala. We’ll port a simple Java class to Scala, and then we’ll dig into Scala’s capabilities. Constructors ...

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