I'd say the only reason its not a static solution to the nullable types
issue is you're example can still easily fail:
a = null;
....
for (p <- person, a <- p.address, z <- a.zipCode) yield zipCode
BLAMO - NPE :-)
On 6/06/12 4:49 PM, Dick Wall wrote:
Well, It's late, and I'm tired, and I haven't read the rest of this
post yet, so I am sure some of this has been answered. In brief though.
Option is absolutely a static type solution to the problem.
Option[String] is not a String. You can't do o.charAt(1) on an
Option[String], but you can do an o.map(_.charAt(1)) on it, and it
will return a None if it was None to begin with, you can also do stuff
like this
for (p <- person, a <- p.address, z <- a.zipCode) yield zipCode
--
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.