A lower bound requires an admissible type argument to be a supertype of a specified type. In Scala,
[V >: U] means . For an immutable software class covariant in U, a method accepting a new output value cannot consume U directly in a contravariant method-parameter position. Instead, add[V >: U](x: V) accepts a possibly wider value and returns a fresh instance parameterized by V. The original narrower instance remains unchanged. The variance-position rule and subtyping justify this widening; a bound alone does not authorize mutating an existing instance through a widened reference.[ref]Scala 2.13 variance annotations specification. Variance Annotations, lower-bound widening in the Sequence.append example
Articles by others on the same topic
There are currently no matching articles.