0

Is there a difference in scala type bound notation direction, as in is [B <: A] the same as [A >: B]?

Caballero
  • 11,546
  • 22
  • 103
  • 163

2 Answers2

2

B <: A means that B has an upper-bound of A. Which means that B can be any type from Nothing to A in the type hierarchy.

A >: B means that A has a lower-bound of B, which means that A can be anything from B to Any in the type hierarchy.

In general, they do not mean the same thing. Each one imposes a bound on a different type parameter. This isn't variance notation either, these are type bounds.

Michael Zajac
  • 55,144
  • 7
  • 113
  • 138
0

Here [B <: A] you declare type B which extends A, here [A >: B] you declare type A which is a parent of type B.

ka4eli
  • 5,294
  • 3
  • 23
  • 43