Hi,
For-comprehensions could help you out:
for{
cookie <- S.findCookie(cookieName)
value <- cookie} doSomethingWithValue
Regards
On Mon, Nov 16, 2009 at 12:07 PM, DMB <[email protected]> wrote:
>
> When I call findCookie it returns a Box. Then, the value on the cookie
> itself is also a box. Hence a ruby one-liner turns into something
> like:
>
> val cookie = S.findCookie(cookieName)
> if(cookie.isDefined) {
> val cookieVal = cookie.open_!.value.openOr(null)
> // Do something with the cookie value
> }
>
> This is very ugly, so I'm guessing I'm doing something wrong, but try
> as I might, I could not find any examples that would look even vaguely
> "right" to me.
>
> Why can't findCookie return a simple, unboxed HTTPCookie object or
> null if cookie is not found?
> Why does the value inside a cookie need to also be Box'ed?
>
> For the sake of comparison, here's how you do the same thing in RoR:
> v = cookies["cookieName"]
> // Do something with the cookie
>
> or ASP.NET:
> var c = Request.Cookies["CookieName"]
> if(c != null) {
> var v = c.Value
> // Do something with the cookie
> }
>
> I fail to see why Lift should be more complicated.
>
> This is with Lift 1.1 M7
> >
>
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---