Accepted answer

Consider the following slightly simpler example:

def foo[A, B](e: Either[A, B]) = e.fold(
  { println("Launch the missiles!"); Left(_) },

Missiles are going to get launched every time you call foo, because the first argument we're passing isn't exactly a function: it's a block that evaluates to a function, and that block's going to get evaluated whether or not the function is used.

See this blog post by Jesse Eichar for a more detailed discussion of this behavior.

Related Query

More Query from same tag