I have a sequence of ids and a function which return an Option[workItem] for each id. All I want to do is generate a sequence of workItem from these two things. I tried various combinations of maps, foreach and for comprehension and nothing works.
def getWorkItems(ids: Future[Seq[Id]]): Future[Seq[Option[WorkItem]]] = {
ids.map {
id: workItemId => id.map(getWorkItem(_)
}
}
This gives me error - Expression of type Seq[Option[WorkItem] doesn't conform to expected type _B
I tried foreach -
def getWorkItems(ids: Future[Seq[Id]]): Future[Seq[Option[WorkItem]]] = {
ids.map {_.foreach(getWorkItem(_)}
}
This gives me error - Expression of type Unit does not conform to expected type _B
I am not sure what this _B type is and how do I go about this transformation.