3 ms·
Nope, it's not the opposite case, I was just to lazy to spell it out. Which way around it is depends on whether it's a return value or parameter. Covariant vs c
by patrec 8y ago
Nope, it's not the opposite case, I was just to lazy to spell it out. Which way around it is depends on whether it's a return value or parameter. Covariant vs contravariant. If it's a parameter an API change from T to Option[T] shouldn't break (you require less), whereas with a return type it's from Option[T] to T (you promise more).
- gr__or 8y agoTo be fair the "result"-part in "something you thought was an Option[T] result turned out to be really a T" makes it sound like you were speaking of the return-type to me as well. I appreciate the elboration though!
- gavinpc 8y agoYes, that was my fault, I overlooked "result," and I also appreciate the clarification. I think the point remains that, while this is not a breaking change from a contractual viewpoint, most type systems would deem it incompatible.