Chapter 2

  1. Which type constraints can you name?

There are two constraints: the lower bound or subtype relation and the upper bound or supertype relation.

  1. What implicit type constraints are added to a type if there are no type constraints defined on it by the developer?

For missing upper bound, the compiler adds Any as a constraint, and, for missing lower bound–Nothing.

  1. Which operators can be used to refer to the nested type of some type?

There are two operators. The notion A#B refers to the nested type of the A type. The notion of a.B refers to the B subtype of the instance a.

  1. Which type can be used as an infix type?

Any type which is parameterized by exactly two type parameters.

  1. Why is the use of structural types discouraged in Scala?

Use of structural types often leads to generated byte code, which accesses methods via reflection, which is slower than normal method calls.

  1. What is expressed via variance?

The correlation between subtyping relations of parameterized and parameterizing types.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.147.58.194