type mismatch;
found : String => Int
required: java.util.function.ToIntFunction[_ >: String]
I really do wish before people wrote up the "next big thing" they got a few language specialists on board who could explain to them that error messages can be one of two things
- a meaningless code
- a fully formed sentence that explains the issue to someone who doesn't understand the language.
The rational being, if you understand the language (eg read the manual), then you just need an error code. But if you don't understand the language (ie the person who is going to get the error message in the first place), then you need a full sentence with explanations, sample problem and solution.
Think of the time saved - the total time of all the developers who might make the error - vs the time cost ( a developer + language specialist writing an explanatory sentence with example ).
String => Int
isscala.Function1[String, Int]
i.e. a Scala function type.java.util.function.ToIntFunction[String]
is a Java function type.In Scala 2.12+ they are supposed to be interchangeable, in earlier versions of Scala you should convert one to another.
How to use Java lambdas in Scala (answer #2)
ToIntFunction[_ >: String]
means that the situation can be a little more complicated because it involves existential types but it's hard to say better without reproducible code sample.Try
Does it work or does error message change?