Skip to content

Instantly share code, notes, and snippets.

@kolov
Last active March 6, 2018 23:00
Show Gist options
  • Save kolov/ee7dd962faa3b932bf938bcead6ab6cd to your computer and use it in GitHub Desktop.
Save kolov/ee7dd962faa3b932bf938bcead6ab6cd to your computer and use it in GitHub Desktop.
def getAllDatesScala(products: List[String]) = {
val futureAllDates = Future.sequence(products.map(p ⇒ getDates(p)))
futureAllDates.map(l ⇒
if (l.exists(_.isLeft))
None
else
Some(l.foldLeft(List[LocalDate]())((acc, e) =>
e match {
case Left(_) => acc
case Right(l) => acc ++ l
})))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment