title: Scala List match last element
body: <p>I'm currently learning Scala and I'm amazed. The language handles so much problems quite elegant. But, I got a problem when it comes to matching the last element of a list.</p>
  <p>Let's have a look at this code:</p>
  <pre><code>def stringify(list: List[String]): String = list match {
    case x :: xs =&gt; x + (if (xs.length != 0) &quot;:&quot; else &quot;&quot;) + stringify(xs)
    case Nil =&gt; &quot;&quot;
  }
  </code></pre>
  <p>This is quite inelegant and I would like to write it more intuitive, something like this:</p>
  <pre><code>def stringify(list: List[String]): String = list match {
    case x :: xs =&gt; x + &quot;:&quot; + stringify(xs)
    case x :: Nil =&gt; x
  }
  </code></pre>
  <p>How can I do that?</p>