title: Writing functions of tuples conveniently in Scala
body: <p>Quite a few functions on <code>Map</code> take a function on a key-value tuple as the argument. E.g. <code>def foreach(f: ((A, B)) ⇒ Unit): Unit</code>. So I looked for a short way to write an argument to <code>foreach</code>:</p>
  
  <pre><code>&gt; val map = Map(1 -&gt; 2, 3 -&gt; 4)
  
  map: scala.collection.immutable.Map[Int,Int] = Map(1 -&gt; 2, 3 -&gt; 4)
  
  &gt; map.foreach((k, v) =&gt; println(k))
  
  error: wrong number of parameters; expected = 1
         map.foreach((k, v) =&gt; println(k))
                            ^
  
  &gt; map.foreach({(k, v) =&gt; println(k)})
  
  error: wrong number of parameters; expected = 1
         map.foreach({(k, v) =&gt; println(k)})
                             ^
  
  &gt; map.foreach(case (k, v) =&gt; println(k))
  
  error: illegal start of simple expression
         map.foreach(case (k, v) =&gt; println(k))
                     ^
  </code></pre>
  
  <p>I can do </p>
  
  <pre><code>&gt; map.foreach(_ match {case (k, v) =&gt; println(k)})
  
  1
  3
  </code></pre>
  
  <p>Any better alternatives?</p>