다음은 최상위 함수, 정적 메소드, 그리고 인스턴스 메소드의 동등성을 테스트하는 예시입니다
voidfoo() {} // A top-level functionclassA {staticvoidbar() {} // A static methodvoidbaz() {} // An instance method}voidmain() {Function 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);}