What does V <: Vector [V] mean in scala?

Hi, I stumbled upon this part of the code, but couldn't figure it out. The confusing place is "V <: Vector [V]", does that mean that V is a subtype of Vector [V]? it is very confusing here.

 trait Vector[V <: Vector[V]] { this: V => def +(other: V): V } 
+4
source share
1 answer

He called the F-limited type of polymorphism and

usually tries when someone tries to solve the general problem of abstraction in object-oriented languages: how to define a polymorphic function, which, although defined in terms of a supertype, when transmitting the value of a subtype will always return the value of the same subtype as its argument .

(from a recent blog post, F-Restricted type of polymorphism is considered complex by " Kris Nuttycombe )

Also see this SO question: What does “Recursive bound type” in Generics mean?

+6
source

All Articles