Know about Scala’s apply() function
1 min readSep 16, 2019
In this blog post I will explain you one of the confusing feature of Scala for beginners i.e apply() method.
In Scala, classes can be constructed without using new keyword, like
val emp = Person()
The reason for this statement to create object is because of apply() function. Person() is not actually a constructor.
In Scala there are several ways to demo this:
val numbers = List(1,2,3,4,5)
In the above example also we are creating object of list without new keyword.