私の限られた知識に基づいて、コンパイラがコレクションの戻り値の型を自動的に継承し、それに基づいて返すコレクションの型を決定することを知っているので、以下のコードで戻りたいと思い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
}
}