In Scala 2.8 is there a way to overload constructors of a case class?
If yes, please put a snippet to explain, if not, please explain why?
In Scala 2.8 is there a way to overload constructors of a case class?
If yes, please put a snippet to explain, if not, please explain why?
You can define an overloaded constructor the usual way, but to invoke it you have to use the "new" keyword.
Overloading constructors isn't special for case classes:
However, you may like to also overload the
apply
method in the companion object, which is called when you omitnew
.In Scala 2.8, named and default parameters can often be used instead of overloading.