Can I use a type bound on a Scala abstract method and then “tighten up” the definition in a subclass?

How about something like this: class CoordSystem class C3D(val x: Double, y: Double, z: Double) extends CoordSystem class C2D(val x: Double, y: Double) extends CoordSystem trait ShapeLike+C.

Thanks very much Jean-Philippe - this worked like a charm! – Alex Dean Oct 6 at 20:16.

A type parameter is a type parameter, and the super class contract demands that you do not tighten its contract -- making it less strict would not violate the contract, though I don't think it is allowed. You can do something else, however: put the type inside the class. Class Shape class CoordSystem class C3D(val x: Double, y: Double, z: Double) extends CoordSystem class C2D(val x: Double, y: Double) extends CoordSystem abstract class Shape { type C.

Thanks Daniel - I thought about this approach (having seen it in the other post). But I couldn't figure out how to make it play nicely with separate classes using Shape and CoordSystem type parameters. With Jean-Philippe's approach I was able to write e.g. Class BlahC – Alex Dean Oct 6 at 20:24.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions