I first read for (x <- xs) yield x * 2 as a loop that returns values, a bit like a Python generator. Then I found code such as for { user <- findUser(id); addr <- user.address } yield addr.city where nothing is a collection; both calls return Option. The same syntax is used with Future.
What is the for ... yield construct really, and what decides the type of the result?




