The idea is to override the copy method (both in the case class and class variants) so that it checks the String that you are copying is valid. Since the types have to line up we would have to throw an exception.
If this isn't done, its possible to to have an instance of JNumber with an invalid number inside.
Agreed. This is necessary if JNumber is going to be a case class. It is a shame, though, because copy isn't the feature of case classes that we want to preserve here.
@sirthias @Ichoran @ktoso
The idea is to override the
copy
method (both in the case class and class variants) so that it checks theString
that you are copying is valid. Since the types have to line up we would have to throw an exception.If this isn't done, its possible to to have an instance of
JNumber
with an invalid number inside.