What does [B >: A] do in Scala?

[B >: A] is a lower type bound. It means that B is constrained to be a supertype of A.

Similarly [B <: A] is an upper type bound, meaning that B is constrained to be a subtype of A.

In the example you’ve shown, you’re allowed to push an element of type B onto a stack containing A elements, but the result is a stack of B elements.

The page where you saw this actually has a link to another page about lower type bounds, which includes an example showing the effect.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)