With reference to the link below Scala: curried constructors
class Person(var name : String, var age : Int, var email : String)
def mkPerson = (n : String) => (a : Int) => (e : String) => new Person(n,a,e)
def makeName(s:String):String="Hello"+s
def makeAge(age:Int):Int=age
def makeEmail(email:String):String=email
val s=mkPerson(makeName("abcd"))
val t1=s(makeAge(2))
val t2=t1(makeEmail("abc@gmail.com"))
I have created methods makeName
,makeAge
,makeEmail
to enrich the values. The actual use case is different
Question
- Is there any possible ways to achieve the above through case classes
- I don't want to use variables
s
,t1
,t2
- Can we achieve the above by Partially applied functions