title: Is it possible to use High order functions with optional arguments
body: <p>I put together a dummy problem to illustrate my point: Say that we have the following handy function to display information about a particular sorting algorithm:</p>
  
  <pre><code>fun sort(name: String, array: Array&lt;Int&gt;, sortingAlgorithm: (Array&lt;Int&gt;) -&gt; Array&lt;Int&gt;) {
      println(name)
      sortingAlgorithm(array).forEach { print(" $it ") }
      println()
  }
  </code></pre>
  
  <p>You would use it like this:</p>
  
  <pre><code>sort("Selection Sort - Θ(n^2)", arrayOf(2, 3, 1), ::selectionSort)
  </code></pre>
  
  <p>And this works because the signature of <code>selectionSort</code> is simple: <code>fun selectionSort(array: Array&lt;Int&gt;): Array&lt;Int&gt; {</code></p>
  
  <p>But say I have another sorting algorithm with the following signature</p>
  
  <pre><code>fun quickSort(array: Array&lt;Int&gt;,
                start: Int = 0,
                end: Int = array.size - 1): Array&lt;Int&gt; {
  </code></pre>
  
  <p>The last two arguments are optional, so in theory you could call <code>quickSort</code> the same way you call <code>selectionSort</code>. That is to say, it stil respects the signature <code>(Array&lt;Int&gt;) -&gt; Array&lt;Int&gt;</code> Right?</p>
  
  <p>Unfortunately when I try to call <code>sort("Quick Sort", arrayOf(2, 3, 1), ::quickSort)</code> I get:</p>
  
  <p><a href="https://i.stack.imgur.com/rVSz8.png" rel="noreferrer"><img src="https://i.stack.imgur.com/rVSz8.png" alt="type missmatch"></a></p>
  
  <p>I think that the compiler isn't being smart enough to realise that those two arguments are optional. How can avoid this problem, other than overloading the <code>sort</code> method to accept a high order function with the signature ?</p>