Scala provides mechanisms
to make method calls look like regular function calls. It uses special case apply and update methods to allow a kind of shorthand call notation that can reduce the clutter of your code.
The apply Method
The
apply method
provides a shorthand way of calling a method on a class. So, as we saw, you can use them as factory-style creation methods, where given some class, such as our old friend Customer:
class Customer(name: String, address: String)
…you can add an apply method to its companion object.
object Customer {
def apply(name: String, address: String) = new ...