Skip to content

Instantly share code, notes, and snippets.

@irof
Created March 27, 2011 03:57
Show Gist options
  • Save irof/888894 to your computer and use it in GitHub Desktop.
Save irof/888894 to your computer and use it in GitHub Desktop.
class C {int m(){1}}
C.metaClass.m = {9}
def a = new C()
assert 9 == a.m()
a.metaClass.m = {2}
assert 2 == a.m()
C.metaClass.m = {8}
a.metaClass.m = {a.&m()}
assert 8 == a.m() // 9になると思った
C.metaClass.m = {7}
a.metaClass.m = {C.&m()}
assert 7 == a.m() // 1になると思った
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment