http://blog.lostlake.org/index.php?/archives/50-The-Scala-Option-class-and-how-lift-uses-it.html

The for comprehension is your friend.

On Wed, Nov 11, 2009 at 2:40 PM, Ferdinand Chan <[email protected]> wrote:

>
> Wondering what's the normal practice of using a Box. As a Java
> developer, I always want to get the boxed value by a method named
> "Value" like
>
> val optionalContent = Full("This is optional")
>
> Log.info( " The optional content is " + optionalContent.value)
>
> But I know its not a valid way to do so in lift ( same for Option in
> Scala)
>
> From the book programming in Scala , there's an example
>
> val withDefault: Option[Int] => Int = {
> case Some(x) => x
> case None => 0
> }
>
> which suggest the use of match to retrieve the value of the boxed
> content. It make sense to me and I'm totally agree with the advantage
> of using match + option (Box) combination.
>
> However, as a newbie to Scala, I'm so tempted to use something
> like .Value to retrieve the box value .
>
> So, what's the normal way to use Box ?? Could someone kindly provide
> some example on how to use ? I tried to look through some source code
> of Lift but its not easy for a newbie :)
>
> Thanks
> >
>


-- 
Lift, the simply functional web framework http://liftweb.net
Beginning Scala http://www.apress.com/book/view/1430219890
Follow me: http://twitter.com/dpp
Surf the harmonics

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