I was following the <guide> of `Chronicle-Wire` li...
# getting-started
f
I was following the guide of
Chronicle-Wire
library, and I found this case: The read operation need a
BiConsumer
value, With Java we can send Setter method but in Kotlin throws compiler error. Some Kotlin expert, can explain to me: Why I can't send the setter method directly and equivalent short-syntax for Kotlin. Method Signature:
Copy code
default <T> WireIn text(T t, @NotNull BiConsumer<T, String> ts) {}
Implementation:
Copy code
// With Java:
wire.read("name").text(this, Data::setName) // Works

// With Kotlin:
wire.read("name").text(this) { obj, name -> obj.name = name } // Works

wire.read("name").text(this, this::setName) // Compile Error: Type mismatch.
wire.read("name").text(this, this::name) // Compile Error: Type mismatch.
s
I think the syntax you're looking for is
Data::name::set
✔️ 1
f
Sam, thx you.
s
Glad I could help!