val user = (User.apply _).tupled(userLikeData)
In short it takes
User.apply as a function first. On every function (here of type
Function3) you can invoke
tupled to convert its parameters list to corresponding tuple type. Because it’s all about
Function the example above can also be written as:
Function.tupled(User.apply _)(userLikeData)
or even simpler:
User.tupled(userLikeData)
//if companion object exists it must extend FunctionX e.g.:
object User extends Function3[String, String, Int, User]
This one is possible only in two cases: either if User doesn’t have companion object or if its companion object extends appropriate FunctionX.
Read more
Login in to like
Login in to comment