title: Implementing an interface with parametrized function
body: <p>Suppose I have an interface</p>
  
  <pre><code>interface A {
      fun  calculate(n: Int): Int
  }
  </code></pre>
  
  <p>I'd like to implement <code>A</code> in a class <code>B</code> (say) so that the <code>calculation</code> is provided in <code>B</code>'s  constructor, something like:</p>
  
  <pre><code>class B (f : (Int) -&gt; Int) : A {
      override fun  calculate(n: Int): Int  //...somehow assign f to calculate
  }
  </code></pre>
  
  <p>Can this be done without making <code>f</code> a property of <code>B</code>?</p>
  
  <p>Hmm... this works:</p>
  
  <pre><code>interface A {
      val calculate: (n: Int) -&gt; Int
  }
  
  class B(f: (Int) -&gt; Int) : A {
      override val calculate = f
  }
  </code></pre>
  
  <p>Can someone explain the intended syntactic difference between <code>fun</code> and <code>val</code> here? I am aware of <a href="https://stackoverflow.com/questions/36118235/function-definition-fun-vs-val">Function definition: fun vs val</a> but would like to get a 'language level' understanding.</p>