I'm assuming that your someThing has a MappedForeignKey trait called user,
right? In that case, you could do this:

somThing.user.map(u => u.firstName.is) openOr "no name"

The Box class has a map function on it that can be used to easily extract
data from a Full Box, but just passes an Empty Box along.

Derek

On Fri, Mar 27, 2009 at 8:27 PM, Alex <[email protected]> wrote:

>
>
> If you have this invalid code:
>
> someThing.user.obj.openOr(...).firstName.is
>
> Maybe there is a way to do this right to cover the possibility that
> the user is Nil, but if not, how about this:
>
> someThing.user.obj.openOr("no name")(_.firstName.is)
>
> Not sure if that's exact scala syntax, but the block would not be
> executed if the default value was returned.
>
> Is there a better way already?
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
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=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to