Suppose I have two functions to get orders and order items:
def getOrders(): Option[List[Int]] = ...
def getOrderItems(orderId: Int): Option[List[Int]] = ...
The simplest modification I could think of is as below:
for{
orderId <- getOrders.getOrElse(Nil)
items <- getOrderItems(orderId)
} yield items
The for comprehension uses the first statement to determins the rest the types. For instance in the above the type List[Int] would be infered and this is different from Option[List[Int]].