title: Scala function pointer
body: <p>Google didn't help me with this question, I hope that doesn't mean it is not possible:</p>
  
  <p>In my class I want to have a method that has a signature defined, but the body is not defined (method1)</p>
  
  <p>There will be many defined methods that satisfy this signature (impl1, impl2, impl3)</p>
  
  <p>When I initialise the object, I will then choose (based on some criteria) which method implementation  impl1, impl2, impl3 to assign to the function pointer method1</p>
  
  <p>Basically I'm asking how I can have a function pointer that can point to any function satisfying its signature.</p>
  
  <p>EDIT:</p>
  
  <p>So, it turns out it is actually very straight forward:</p>
  
  <pre><code>var method: Int =&gt; Int = (x =&gt; x+1)
  
  method = (x =&gt; x-1)
  method = (x =&gt; x*2)
  etc...
  </code></pre>
  
  <p>My problem before was that I was using "val" or "def" to define "method"</p>
  
  <p>Not sure why this wasn't suggested directly. Many people favoured the way of having the function as a parameter to some secondary class then initialise that class with a specific implementation. Maybe there is something that I'm missing.</p>
  
  <p>EDIT 2: I realise now that I didn't get the answer I was looking for because I didn't word my question properly, I should have said that I wanted "delegate" behaviour as it is in C#.</p>