Is it possible to get all entries of a List[Option[T]] having a value?
Example:
val list = List(None, Some(1), None, Some(2))
list.filter(_.isDefined).map(_.get)
result:
List[Int] = List(1, 2)
Is there a method to do it in one step? It’s a common case, isn’t it?
Note that
Will do just as well.