You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We have also simplified `ListNode` to leverage its `case class` fields, and `Nil` to be a singleton object; it is a "node of nothing" because it does not hold an element. The type parameter for `Node` is `B` to suggest we want to store birds at each node.
The `Node[Bird]` can be assigned the `africanSwallowList` but then accept `EuropeanSwallow`s.
77
+
The covariant type parameter allows `birds` to get the value of `africanSwallows`.
78
+
79
+
The type bound on the type parameter for `prepend` allows adding different varieties of swallows and getting a wider type: instead of `Node[AfricanSwallow]`, we get a `Node[Bird]`.
80
+
81
+
The canary in the coal mine is `-Xlint`, which will warn if the type arg is widened too much.
0 commit comments