I am new to Scala and I have a case class like this:
case class Student(
name: String,
age: Option[Int] = None,
id: String
)
and another case class like this:
case class Member(
id: String,
`type`: String,
name: String
)
I want to create a helper implicit in such a way that:
case class Member(
id: String,
`type`: String,
name: String
)
object Member {
implicit def toStudent(member:Member):Student = Student(member.name,None,member.id)
}
and then call the method like this:
val newMember = Member("abc","Student","John")
val student = newMember.toStudent
or something fancy like that. Would this be possible in Scala as I see a lot of fancy syntax similar to this at a lot of places?