Skip to content

Instantly share code, notes, and snippets.

@sullivan-
Created February 19, 2013 04:43
Show Gist options
  • Save sullivan-/4983186 to your computer and use it in GitHub Desktop.
Save sullivan-/4983186 to your computer and use it in GitHub Desktop.
def bothGrandfathersNoFlatMapNoPairMatch(p: Person): Maybe[(Person, Person)] =
p.mother match {
case Just(m) =>
p.father match {
case Just(f) =>
m.father match {
case Just(fm) =>
f.father match {
case Just(ff) => Just((fm, ff))
case _ => MaybeNot
}
case MaybeNot => MaybeNot
}
case MaybeNot => MaybeNot
}
case MaybeNot => MaybeNot
}
assertBothGrandfathers(bothGrandfathersFlatMap, bothGrandfathersNoFlatMapNoPairMatch)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment