【发布时间】:2013-03-19 13:27:51
【问题描述】:
根据我有限的知识,我知道编译器会自动继承集合返回类型,并据此确定要返回的集合类型,因此在下面的代码中我想返回 Option[Vector[String]]。
我尝试使用下面的代码,但我得到了编译错误
type mismatch; found : scala.collection.immutable.Vector[String] required: Option[Vector[String]]
代码:
def readDocument(v:Option[Vector[String]]) : Option[Vector[String]] =
{
for ( a <- v;
b <- a )
yield
{
b
}
}
【问题讨论】:
标签: scala