December 2022
Intermediate to advanced
400 pages
10h 2m
English
Topics in This Chapter A1
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. This chapter also covers enumerated types.
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 or traits.
The apply method of an object is usually used for constructing new instances of the companion class.
If you don’t ...
Read now
Unlock full access