Scala: ignore future return value, but concatenate them

How to write code when I do not need to return a value.

Example:

for { a <- getA // I do not care about a, but I need to wait for the future to finish b <- getB } yield (b) 
+7
scala future for-comprehension
source share
2 answers

Like this

 for { _ <- getA b <- getB } yield (b) 
+9
source share

Or, if not for the fan of understanding, you can do

 getA.flatMap(_ => getB ) 

But I think most people will vote for understanding

+2
source share

All Articles