Pattern: Use of implicit .call
tear off
Issue: -
DO explicitly tear off .call
methods from objects when assigning to a Function
type. There is less magic with an explicit tear off. Future language versions
may remove the implicit call tear off.
Example of incorrect code:
class Callable {
void call() {}
}
void callIt(void Function() f) {
f();
}
callIt(Callable());
Example of correct code:
class Callable {
void call() {}
}
void callIt(void Function() f) {
f();
}
callIt(Callable().call);