Marcus Fihlon
04/03/2018, 11:12 AMpublic static Reply of(Consumer<Update> action, Predicate<Update>... conditions)
This is the Java code, where I make use of the above API method:
return Reply.of(update -> silent.send("Nice pic!", getChatId(update)), Flag.PHOTO);
If I let IntelliJ IDEA convert this code to Kotlin, this is the result:
return Reply.of({ update -> silent.send("Nice pic!", getChatId(update)!!) }, Flag.PHOTO)
Now, I get the following error message:
Error:(77, 25) Kotlin: Type mismatch: inferred type is (Update) -> Optional<Message!>! but Consumer<Update!>! was expected
This is where I’m stuck. I know that Kotlin treats consumers and producers differently. What must the code look like? And why?