map2 in scala in Exception Handling

Viewed 1228
def map[B] (f: A=>B) : Option[B]

def flatMap[B] (f: A=>Option[B]) : Option[B] 

def map2[A,B,C] (ao: Option[A], bo: Option[B]) (f: (A,B) => C) :Option[C] =
ao.flatMap(aa=>
  bo.map(bb=>
    (f(aa,bb))))

Here is the definition of map and flatMap in Exception Handling and I have this map2 formed on the basis of map and flatMap. It is really hard to understand the formation of map2. Can some one explain the role of flatMap and map in map2. Thank you

2 Answers
Related