Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Replace the last <code>=</code> with <code>=&gt;</code>. The <code>=&gt;</code> symbol, when in a value position, separates the arguments from the function's implementation.</p> <p>You declare what the function compose takes but don't declare what it returns. So I am not sure what you want. There are two possibilities here. </p> <p>You may want the result of composition applied to a value, in that case it needs the value:</p> <pre><code>scala&gt; val compose = (a: Double =&gt; Double, b: Double =&gt; Double, arg:Double) =&gt; b(a(arg)) compose: (Double =&gt; Double, Double =&gt; Double, Double) =&gt; Double = &lt;function3&gt; </code></pre> <p>It takes two functions, composes them and apply the <code>arg</code>.</p> <p>You may also want the function produced by the composition of two functions:</p> <pre><code>scala&gt; val compose = (a: Double =&gt; Double, b: Double =&gt; Double) =&gt; { x:Double =&gt;b(a(x)) } compose: (Double =&gt; Double, Double =&gt; Double) =&gt; Double =&gt; Double = &lt;function2&gt; </code></pre> <p>Notice now that we have a Function2, instead of a Function3 and the return after the first set of arguments is a another function.</p> <p>We could do it a bit differently:</p> <pre><code>val compose: (Double =&gt; Double, Double =&gt; Double) =&gt; Double =&gt; Double = (a,b) =&gt; { x =&gt; b(a(x)) } </code></pre> <p>One of the problems here is that the usage of the <code>=&gt;</code> in a type position is slightly different than its usage in a value position. In a value the position, it must have argument names and the types annotation in these arguments are hints for the Scala inferrer and the return can't be declared, which the inferrer fills for us. Hence, my doubt in what you wanted.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload