Function references with default parameters



I would like to pass path.toFile()::readText to a function which accepts () -> String.
The problem is that the readText() method has a parameter named charset. Then the function looks like (Charset) -> String. It works that way but I assumed that the charset can be omitted because it is a default parameter.

The two workarounds are:

  1. (as already explained) change the signature of the method that accepts the function to (Charset) -> String
  2. write it as a lambda: `{ path.toFile().readText() }

But path.toFile()::readText to () -> Stringis not possible.

Any ideas?


This is a known issue and it’s going to be supported in a future release: