Cover page by Cay S. Horstmann

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

O'Reilly logo

Chapter 6. Objects

Topics in This Chapter image

6.1 Singletons — page 65

6.2 Companion Objects — page 66

6.3 Objects Extending a Class or Trait — page 67

6.4 The apply Method — page 67

6.5 Application Objects — page 68

6.6 Enumerations — page 69

Exercises — page 71

In this short chapter, you will learn when to use the object construct in Scala. Use it when you need a class with a single instance, or when you want to find a home for miscellaneous values or functions.

The key points of this chapter are:

• Use objects for singletons and utility methods.

• A class can have a companion object with the same name.

• Objects can extend classes ...

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