whatever.map(....).openOr(..) is the usual idiom, however, you could of course use parameter extraction if that floats your boat / is appropriate.
Cheers, Tim On 23 Dec 2009, at 23:11, Jim Wise wrote: > Oh, I see -- because x.map(foo) where x is a Box returns a Box which > is Empty/Error or Full(foo(a.open)) depending on whether x was Full. > > Thank you! > > Sent from my iPhone > > On Dec 23, 2009, at 17:06, Ross Mellgren <dri...@gmail.com> wrote: > >> Normally you'd probably do something like >> >> i.category.obj.map(_.name).openOr("unknown category!") >> >> That is, if I have a category object give me its name, otherwise give >> me "unknown category!" >> >> Also, if you have to collect the result a bunch of possibly-failing >> computations (like looking up the category can fail) then remember >> that the for comprehension is your friend. >> >> -Ross >> >> On Dec 23, 2009, at 4:45 PM, Jim Wise wrote: >> >>> Jim Wise <jw...@draga.com> writes: >>> >>>> "category" -> >>>> i.category.obj.open_!.name, // XXX safe unless key rel is >>>> corrupt ? >>>> AttrBindParam("imgUrl", i.url, "src") >>> >>> And, since I'm looking at this code, what's the safe way to do this >>> (i.e. can I avoid the open_!)? >>> >>> -- >>> Jim Wise >>> jw...@draga.com >> >> -- >> >> You received this message because you are subscribed to the Google >> Groups "Lift" group. >> To post to this group, send email to lift...@googlegroups.com. >> To unsubscribe from this group, send email to >> liftweb+unsubscr...@googlegroups.com >> . >> For more options, visit this group at >> http://groups.google.com/group/liftweb?hl=en >> . >> > > -- > > You received this message because you are subscribed to the Google Groups > "Lift" group. > To post to this group, send email to lift...@googlegroups.com. > To unsubscribe from this group, send email to > liftweb+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/liftweb?hl=en. > > > -- You received this message because you are subscribed to the Google Groups "Lift" group. To post to this group, send email to lift...@googlegroups.com. To unsubscribe from this group, send email to liftweb+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/liftweb?hl=en.