title: scala.MatchError: <SomeStringvalue> (of class java.lang.String)
body: <p>I was getting the error:</p>
  
  <pre><code>Exception in thread "main" scala.MatchError: SomeStringValue (of class java.lang.String)
  </code></pre>
  
  <p>I found that it was causing because of "SomeStringValue" was not present in any of the cases:</p>
  
  <pre><code>val test = "SomeStringValue"
  test match {
    case "Name" =&gt; println("Name")
    case "Age"  =&gt; println("Age")
    case "Sex"  =&gt; println("Sex")
  }
  </code></pre>
  
  <p>When I added the else case: _ it ran correctly as below. </p>
  
  <pre><code>val test = "SomeStringValue"
  test match {
    case "Name" =&gt; println("Name")
    case "Age"  =&gt; println("Age")
    case "Sex"  =&gt; println("Sex")
    case _      =&gt; println("Nothing Matched!!")
  }
  </code></pre>
  
  <p>Question: What is the reason that there should always be a matching value in the case construct in Scala?</p>