Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def thenNullCheck[A, B, C](f: A => B, g: B => C) = {
- optional(f).andThen(optional(g))
- }
- val nullCheckedComposition = thenNullCheck(getUser, getInfo) // nullCheckedComposition: Long => Info
- nullCheckedComposition(null.asInstanceOf[Int]) // res10: Info = null
- nullCheckedComposition(123) // res11: Info = Info(Tom)
- nullCheckedComposition(1234) // res12: Info = null
Add Comment
Please, Sign In to add comment