I canβt understand how this code works?
class Node[TypeOne <: Node[TypeOne]] {
var x: TypeOne = _
}
object Tree extends App {
val treeNode = new Node[String]
treeNode.x = "ten"
//treeNode.x = new TreeNode[String]
}
I originally thought of the Node signature class [TypeOne <: Node [TypeOne]], it meant that any type x variable of type TypeOne should be of type Node or its subclass, but it doesn't seem like that, since I can create a val treeNode of type Node [ String] and Node [Int]. So what does this signature do?
source
share