- Ruby 初心者スレッド Part 57©2ch.net [転載禁止]©2ch.net
580 :デフォルトの名無しさん[sage]:2015/10/31(土) 11:45:00.47 ID:zwNlcJhb - >>569
よくわかんないけど、こういうんじゃダメなの? module M; def foo; p "foo" end end class Module def my_exec(p, &b); module_exec{ b.call(p) }; self end end obj = Object.new obj.extend M.my_exec("bar"){ |s| define_method(:bar){ p s } } obj.foo #=> "foo" obj.bar #=> "bar"
|
|