I have the following Scala class:
class Person(var name : String, var age : Int, var email : String)
I would like to use the Person constructor as a curried function:
def mkPerson = (n : String) => (a : Int) => (e : String) => new Person(n,a,e)
This works, but is there another way to accomplish this? This approach seems a bit tedious and error-prone. I could imagine something like Function.curried, but then for constructors.
This will work:
def mkPerson = (new Person(_, _, _)).curried
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With