Want to retrieve specific element from the input class while making the list of an output case class.
Example :
case class Student(id:Int, grade:Int, marks:Int)
case class StudentID(id:Int,grade:Int)
val inputList= Option[List(Student(1,100,234) ,Student(2,200,453), Student(3,300,556))]
val outputList=List(StudentID(1,100),StudentID(2,200),StudentID(3,300)) //result
I am trying to get only the id and grade. Please suggest.
Also, the problem is input list is Option[].
val a = inputList.iterator.flatMap{ i=> outputList(i.map(_.id)) }