title: Scala's choice in implementing Option
body: <p>How it's done in Scala:</p>
  
  <pre><code>  sealed trait Option[+A] {
      def get: A
      def isEmpty: Boolean
      def map[B](f: A =&gt; B): Option[B] =
        if (isEmpty) None else Some(f(this.get))
    }
    object None extends Option[Nothing] {
      def isEmpty = true
      def get = throw new NoSuchElementException("None.get")
    }
    case class Some[+A](x: A) extends Option[A] {
      def isEmpty = false
      def get = x
    }
  </code></pre>
  
  <p>How I would assume it in OOP world:</p>
  
  <pre><code>  sealed trait Option[+A] {
      def map[B](f: A =&gt; B): Option[B]
    }
    object None extends Option[Nothing] {
      def map[B](f: Nothing =&gt; B): Option[B] = this
    }
    case class Some[+A](get: A) extends Option[A] {
      def map[B](f: A =&gt; B): Option[B] = Some(f(get))
    }
  </code></pre>
  
  <p>What's wrong with the latter? </p>
  
  <p><a href="http://www.manning.com/bjarnason/" rel="noreferrer">Functional programming in Scala</a> is using <code>match</code> in <code>Option[A]</code> trait, which is the third way (looks like Haskell, but why?) Why not utilize subtype polymorphism?</p>
  
  <p><strong>UPDATE</strong>: Third way I mentioned:</p>
  
  <pre><code>sealed trait Option[+A] {
    def map[B](f: A =&gt; B): Option[B] = this match {
      case None =&gt; None
      case Some(a) =&gt; Some(f(a))
    }
  }
  object None extends Option[Nothing] {
  }
  case class Some[+A](get: A) extends Option[A] {
  }
  </code></pre>