For example, I have this case class:
case class Student (firstName : String, lastName : String)
If I use this case class, is it possible that supplying data to the fields inside the case class are optional? For example, I’ll do this:
val student = new Student(firstName = "Foo")
Thanks!
If you just want to miss the second parameter without a default information, I suggest you to use an
Option.Now you might create instances this way:
To make it usable as you wanted it, I will add an implicit:
Now you are able to call it those ways: