title: How to overload scala function apply methods
body: <p>As a follow on to: <a href="https://stackoverflow.com/questions/7340995/scala-loan-pattern-optional-function-param">scala loan pattern, optional function param</a></p>
  
  <p>What would the proper syntax be to move the withLoaner param to overloaded apply methods? I've tried several versions of the following unsuccessfully. Also, any insights into my error conceptually very appreciated.</p>
  
  <pre><code>def withLoaner = new {
    def apply(n:Int, op: Int =&gt; String):String = (1 to n).map(op).mkString("\n")
    def apply(n:Int, op: () =&gt; String):String = apply{n, i:Int =&gt; op()} // no compile
    def apply(op: () =&gt; String):String = apply{1, i:Int =&gt; op()} // no compile
  }
  </code></pre>