E086: Wrong Number Of Parameters
This error is emitted when a function literal has a different number of parameters than what is expected by the context.
When you provide a function literal where a specific function type is expected, the number of parameters in your literal must match the expected function type.
Example
val f: (Int, Int) => Int = x => x + 1
Error
-- [E086] Syntax Error: example.scala:1:29 -------------------------------------
1 |val f: (Int, Int) => Int = x => x + 1
| ^^^^^^^^^^
| Wrong number of parameters, expected: 2
|-----------------------------------------------------------------------------
| Explanation (enabled by `-explain`)
|- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
| The function literal
|
| x => x + 1
|
| has 1 parameter. But the expected type
|
| (Int, Int) => Int
|
| requires a function with 2 parameters.
-----------------------------------------------------------------------------
Solution
// Provide the correct number of parameters
val f: (Int, Int) => Int = (x, y) => x + y
// Or change the expected type
val f: Int => Int = x => x + 1
In this article