On Tue, Oct 30, 2012 at 7:11 PM, Josh Berry <[email protected]> wrote:

> On Tue, Oct 30, 2012 at 10:03 PM, Ricky Clarkson
> <[email protected]> wrote:
> > As for pattern-matching, there's nothing inherently bad about it, but
> > usually or perhaps always with scala.Option, there's a better way of
> > writing code using HOFs.
>
> So, in my example, what should I have done instead?  I should say the
> function returning an Object that might be null was from a java
> library.  And the "do something with class I know" was less than 2
> lines in each case.  Seemed perfectly succinct and readable.
>

It depends on the functions that you are calling in the Some and None
cases: if they belong to an external API, extracting the value is your only
opt... er... choice. However, if you are calling methods that you wrote,
consider rewriting them to accept an Option and just call flatMap with that
method on your option.

-- 
Cédric

-- 
You received this message because you are subscribed to the Google Groups "Java 
Posse" 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/javaposse?hl=en.

Reply via email to