Scala blends functional and object-oriented programming in many nice ways. You can use both FP an OO-like constructs whichever fits the current problem better. But there’s always room for improvement! Here’s one thing I think is missing (short version at the bottom).

FP side

It’s easy to convert a method to a function in Scala. For example, if you have a method:

def say(to: Person, what: String): String = { ... }

we can get the corresponding function using the underscore notation:

val sayFun: (Person, String) => String = say _

Moreover, Scala supports multiple parameter lists, which is sometimes also referred to as currying, and which makes partial application easier:

OO side

One thing every class has is a constructor. But what is a constructor, really? You give values for the constructor’s arguments, and get a new instance of the class in return. So it’s really just a function!

Link?

However, that’s where the combination of OO and FP fails in Scala: you can’t use the two features of methods (convert to function, currying) mentioned above with constructors. Both of these won’t work:

But that requires repeating the signature of the constructor in the companion object, and nobody likes code duplication, right? ;)

Use-case

Where can this be useful? For example in the classic factory example. Imagine you have a class which depends on some services, but also on some data available on runtime. Of course we use IoC so instances of the other services are provided to our class: