I\'m trying to do the following
interface Updater {
void update(String value);
}
void update(Collection values, Updater updater) {
upd
A Function
returns a value, even if it is declared as being of type Void
(you will have to return null
then. In contrast, a void
method really returns nothing, not even null
. So you have to insert the return
statement:
void update(Collection values, Updater updater) {
update(values, s -> { updater.update(); return null; }, 0);
}
An alternative would be to change the Function
to Consumer
, then you can use the method reference:
void update(Collection values, Updater updater) {
update(values, updater::update, 0);
}
void update(Collection values, Consumer fn, int ignored) {
// some code
}