Testing functions for equality
Here’s an example of testing top-level functions, static methods, andinstance methods for equality:
void foo() {} // A top-level functionclass A {static void bar() {} // A static methodvoid baz() {} // An instance method}void main() {var x;// Comparing top-level functions.x = foo;assert(foo == x);// Comparing static methods.x = A.bar;assert(A.bar == x);// Comparing instance methods.var v = A(); // Instance #1 of Avar w = A(); // Instance #2 of Avar y = w;x = w.baz;// These closures refer to the same instance (#2),// so they're equal.assert(y.baz == x);// These closures refer to different instances,// so they're unequal.assert(v.baz != w.baz);}