Given the following snippet:
I expect the return value to be [1,2,nil], but it returns [1,2] instead.
My rationale is that the matching function is...
... so the return type of flatMap must be [Int?] to match the type of a, that implies T is Int?. That means the return type of transform must be Int??. Our closure returning Int? is properly accepted as it is covariant . However, my expectation is that if our closure returns .None it would be treated as .Some(.None) ultimately by the transform, since .None is a valid Int? for wrapping in Int??.
: Indeed, this code does not compile in 2.0, before closure covariance support was added.