I had a case class with a option parameter, let's say:
case class Student(id: Option[Int], name: String)
To get a Student instance, not only I could use Student(Some(1), "anderson")
, I also want this form to be a valid way Student(2,"Sarah")
I guess I have to create a Int => Option[Int]
and put it somewhere. So what's the best way to do so?
Update
As mentioned in the comment, override apply
method will block calling it by Student.apply _