Created
October 10, 2010 15:54
-
-
Save nbqx/619342 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// g100pon #69 動的なメソッド追加 | |
class MyClass{ | |
def say = { | |
println "g100pon!!" | |
} | |
} | |
def cls = new MyClass() | |
cls.say() | |
cls.metaClass.define{ | |
sayTwice{ 2.times{say()} } | |
"3度言う"{ 3.times{say()} } | |
} | |
cls.sayTwice() | |
cls."3度言う"() | |
cls.metaClass."そこまで言う" << { println "これでもいいんだよ" } | |
cls."そこまで言う"() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment