You can define patterns to match on non-case classes with "extractors".
See, e.g., http://www.scala-lang.org/node/112 or the "Extractors" chapter
from Programming in Scala.

--j

On Mon, Nov 10, 2008 at 8:49 PM, Erick Fleming <[EMAIL PROTECTED]>wrote:

> I've been trying to get my head wrapped around pattern matching and in
> particular trying to understand how the RequestState/Req type works in Lift.
>
> LiftRules.addDispatchBefore {
>   case RequestState("login" :: Nil, "", PostRequest) => LoginOps.login
>   case RequestState("logout" :: Nil, "", _) => LoginOps.logout
>   case RequestState("/" :: page, "", _)
>     if User.isNotAuthenticated =>
>       RequestedURL(Full(S.uri))
>       () => Full(RedirectResponse("/login"))
>     }
> }
>
> The previous code works and seems straight forward to me, but looking at
> Lift's code confuses me.  RequestState/Req class has more than three
> arguments in the constructor, how can you pattern match on only three
> arguments and I also thought that the class needed to be a case class.
>
> Sorry for the basic question.
>
> >
>

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