Created
February 18, 2009 06:47
-
-
Save jugyo/66232 to your computer and use it in GitHub Desktop.
This file contains 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
class Foo | |
def define_singleton_method(name, &block) | |
extend Module.new{define_method name, &block} | |
end | |
end | |
f = Foo.new | |
f.define_singleton_method(:hoge) do |arg| | |
puts arg | |
end | |
f.hoge('aaaaaaa') | |
# 特異メソッドを定義するメソッド | |
# see also: http://d.hatena.ne.jp/h-hirai/20080627/1214536733 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment