score:86

Accepted answer

You can also write

(Person.apply _).tupled

to avoid repeating the types.

score:4

To build on some of the other comments you could do the following as well since tuple is calling the generated default apply method for the case class.

object Person {
  ...
  def tupled = (this.apply _).tupled
}

score:7

One workaround is define a companion object as follows:

object Person extends((String,String) => Person) {
    ...
}

See. https://groups.google.com/d/msg/scala-user/jyWBMz5Qslw/Bryv4ftzRLgJ

score:25

This is very similar to what Alexey Romanov said, but in order to avoid lifting apply whenever you need tupled, we just add it to our companion objects.

object Person {
  def something = "rawr"
  def tupled = (Person.apply _).tupled
}

Now you can call Person.tupled just like you would have if it didn't have a companion object.


Related Query

More Query from same tag