DMB <[email protected]> writes:

> Hmm, apparently all generators must be of the same type or down-cast
> to the same type. So
>
>         def masters = for {
>             sy <- selectedYear
>             sm <- selectedMonth
>             m = Master.getMastersWithTags(sy, sm)
>         } yield m
>
>         m.get // Do something with the list
>
> does the trick, but it's non-idiomatic.

Maybe. I was a bit surprised with this at first, but now it seems I'm
used to it :-) 

It boils down to the fact that for comprehensions are syntactic sugar on
top of map/flatMap/filter. You can see how the translation is done here:
http://programming-scala.labs.oreilly.com/ch13.html#OptionsAndForComprehensions

In essence, the result of the for{} yield has the same collection as
found in the first generator. In your case the first generator has type
Option[T] so the result of the expression is Option[Y] (where possibly X
!= Y)

/Jeppe

--

You received this message because you are subscribed to the Google Groups 
"Lift" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/liftweb?hl=.


Reply via email to