Skip to content

Instantly share code, notes, and snippets.

@nobeans
Created January 27, 2016 08:48
Show Gist options
  • Save nobeans/992838df867c5a1cfe6f to your computer and use it in GitHub Desktop.
Save nobeans/992838df867c5a1cfe6f to your computer and use it in GitHub Desktop.
staticメソッドの隠蔽
class Parent {
def hoge() {
aaa()
}
def foo() {
aaa()
}
static aaa() {
"PARENT"
}
}
class Child extends Parent {
def hoge() {
aaa()
}
static aaa() {
"CHILD"
}
}
assert new Parent().hoge() == 'PARENT'
assert new Parent().foo() == 'PARENT'
assert Parent.aaa() == 'PARENT'
assert new Child().hoge() == 'CHILD'
assert new Child().foo() == 'PARENT'
assert Child.aaa() == 'CHILD'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment