The reason is that Option acquired a flatten
method in 2.10, that works only on nested Option
s.
In 2.9, the call to flatten was added by an implicit conversion to Iterable
, and the result was an Iterable
(or a subtype thereof, depending on the nested value inside Option
).
Here's the signature of flatten
in 2.10:
def flatten[B](implicit ev: <:<[A, Option[B]): Option[B]
It says: if you can find evidence that the element inside this option is an Option
itself, say Option[B]
, I can flatten that and return an Option[B]
.
Implicits are only tried if there is no method with that name, so that explains why it doesn't fall back to the 2.9 method.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…