381806 (2) [Avatar] Offline
I completed the map2 function for this exercise but then realised I don't understand some of the syntax and what's going on with scoping etc in scala. Here's my implementation of map2:

 def map2[EE >: E, B, C](b: Either[EE, B])(f: (A, B) => C): Either[EE, C] = {
    this flatMap(aa => b map (bb => f(aa, bb)))

What I don't understand is how the 'aa' value is pulled into the flatMap function. I know it is of type 'A' and that this function exists within a trait of type:

sealed trait Either[+E,+A] {

But what I don't understand is how the compiler knows to put 'this' into value 'aa' - I'm guessing it has something to do with one of the following:

type classes

but I don't know which and I don't know how to find more information on this feature of the scala language.