Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我想过滤选项类型Seq,Some并提取内容。
Seq
Some
是否有一个函数调用来执行此操作?
val list = optionList.flatMap(_.toList)
正如 sschaef 在评论中指出的那样,您可以使用flatten:
flatten
val list = optionList.flatten
optionList.collect { case Some(x) => x }