In Programming in Scala 2nd Edition in section 19.5 in following example
class Queue[+T] (private val leading: List[T],
private val trailing: List[T] ) {
def enqueue[U >: T](x: U) =
new Queue[U](leading, x :: trailing) // ...
}
T
should end up at negative position like below
def enqueue[U- >: T-](x: U-) =
new Queue[U](leading, x :: trailing) // ...
But the book mentions that there are 2 flips
Technically, what happens is a flip occurs for lower bounds. The type parameter U is in a negative position (1 flip), while the lower bound (>: T) is in a positive position (2 flips).
How 2 flips occur here?