title: Scala syntax for do-nothing function?
body: <p>Is there some standard way in Scala of specifying a function that does nothing, for example when implementing a trait? This works:</p>
  
  <pre><code>trait Doer {
    def doit
  }
  
  val nothingDoer = new Doer {
    def doit = { }
  }
  </code></pre>
  
  <p>But perhaps there is some more congenial way of formulating nothingDoer?</p>
  
  <p><strong>Edit</strong> Some interesting answers have appeared, and I add a little to the question in response. First, it turns out that I could have used a default implementation in Doer. Good tip, but you don't always want that. Second, apparently a more idiomatic way of writing is:</p>
  
  <pre><code>val nothingDoer = new Doer {
    def doit { }
  }
  </code></pre>
  
  <p>Third, although nobody suggested exactly that, I found that this also seems to work:</p>
  
  <pre><code>val nothingDoer = new Doer {
    def doit = Unit
  }
  </code></pre>
  
  <p>Is this a good alternative?</p>
  
  <p>(The ":Unit" that a few people suggested does not really add anything, I think.)</p>