How to combine Option values in Scala?
- by Jeff
Hi!
I want to be able to apply an operation f: (T,T) => T to two Option[T] values in Scala. I want the result to be None if any of the two values is None.
More specifically, I want to know if is there a shorter way to do the following:
def opt_apply[T](f: (T,T) => T, x: Option[T], y: Option[T]): Option[T] = {
(x,y) match {
case…