Skip to content

Instantly share code, notes, and snippets.

@MateuszKubuszok
Created August 22, 2017 12:08
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MateuszKubuszok/ad411d1bd7bd27da2750c7108eae0d73 to your computer and use it in GitHub Desktop.
Save MateuszKubuszok/ad411d1bd7bd27da2750c7108eae0d73 to your computer and use it in GitHub Desktop.
implicit final class OptMapOps[A](self: A) {
def optMap[B, C >: A](otherOpt: Option[B])(f: (A, B) => C): C = otherOpt match {
case Some(other) => f(self, other)
case None => self
}
}
// sequence.mapOps(optionalFilter) { case (seq, filter) => filter(seq) }.otherOps(args)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment