companion objects

Companion Object in Scala

Reading Time: 4 minutes Companion Object is a singleton object of a class sharing same name and same source file.The class is called a Companion Class.For instance, we have a class name Person in Person.scala and an singleton object Person in the same file: In this file the object Person is a companion object and class Person is a companion class. Benefits of Companion Object Companion Objects in Scala gives many benefits.First, companion object and class can access each Continue Reading

Scala Beginner Series (2) : Object Oriented Scala

Reading Time: 7 minutes This series is all about the taste of Scala.It is best suitable for all the newbies in Scala. You may also like: Scala Beginner Series (1) : Basics In the previous part, we covered: Values, variables, expressions and types Functions and recursion The Unit type This article will cover the object oriented nature of Scala language. Classes Scala has the same concept of a class as we Continue Reading