https://redmine.ruby-lang.org/https://redmine.ruby-lang.org/favicon.ico?17113305112012-04-22T08:17:49ZRuby Issue Tracking SystemRuby master - Feature #6336: Allow Ruby hacker to extend a module or a class, without needing to know if it is a module or a classhttps://redmine.ruby-lang.org/issues/6336?journal_id=260702012-04-22T08:17:49Zshevegen (Robert A. Heiler)shevegen@gmail.com
<ul></ul><p>What I meant to say is - I think adding a new keyword would not be a good<br>
solution.</p> Ruby master - Feature #6336: Allow Ruby hacker to extend a module or a class, without needing to know if it is a module or a classhttps://redmine.ruby-lang.org/issues/6336?journal_id=260712012-04-22T08:33:24Zmame (Yusuke Endoh)mame@ruby-lang.org
<ul><li><strong>Status</strong> changed from <i>Open</i> to <i>Rejected</i></li></ul><p>I don't know why do you want to do such a thing, but you can use Module#module_eval for both class and module:</p>
<p>Foo.module_eval do<br>
def test<br>
puts 'This is test from module Foo, but modified.'<br>
end<br>
end<br>
Bar.module_eval do<br>
def test<br>
puts 'This is test from module Bar, but modified.'<br>
end<br>
end</p>
<p>Adding a keyword for this requires a much more good reason.</p>
<p>--<br>
Yusuke Endoh <a href="mailto:mame@tsg.ne.jp" class="email">mame@tsg.ne.jp</a></p>