title: Which ways to introduce a new variable in Scala exist?
body: <p>It is well-known that a programmer can declare a new variable in Scala by using <code>val</code> or <code>var</code>, like this: </p>
  
  <pre><code>val x = 10 //x is now defined and an Integer.
  </code></pre>
  
  <p>A function parameter also introduces a new variable: </p>
  
  <pre><code>def fun(y: String) {
      //y of type String is now available here
  }
  </code></pre>
  
  <p>These are straight forward examples. However, there are more ways to declare a variable in a given context. </p>
  
  <p>For instance, a <code>match</code> expression can also introduce new variables: </p>
  
  <pre><code>val z = 10
  z match {
       case w: Int =&gt; w //w is a valid variable of type Int in this scope
  }
  </code></pre>
  
  <p>What are further commands which introduce variables into a certain scope in Scala? </p>
  
  <p><em>Background for the interested:</em></p>
  
  <p>I'm using this in a macro which finds variable definitions (ValDefs) in the abstract syntax tree. <code>match</code> expressions or function definitions generate a different syntax tree than normal ValDefs, which I have to take care of. Since I want my macro to be robust, I want to test it against all possible forms of variable declarations.</p>
  
  <p><em>Notes on comments:</em></p>
  
  <p>Method definitions with <code>def</code> are not of concern. Furthermore, I am only interested in variables which are visible in the source code and can be referenced by some term. </p>