I have a Seq[Option[String]], let's say the values are surnames to be used
in a mail merge.  If we don't know the surname then we just want to "print"
an empty string in its place:

val surnames: Seq[Option[String]] = ...
val default = ""
val surnamesForMerge = surnames map {_ getOrElse default}


I don't know that any given entry will never be None, but I *do* know what
default I want if it is.



On 5 June 2012 22:14, Cédric Beust ♔ <[email protected]> wrote:

> On Tue, Jun 5, 2012 at 2:11 PM, Kevin Wright <[email protected]>wrote:
>
>> Nat Price's solution does offer some nice extra goodies though,
>> `otherwise` is very handy for providing default values
>
>
> Providing default values seems to be antithetical to Option, though.
> What's the point of creating an Option if you know it will never be None?
>
> --
> 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