From: Marc Heiler Date: 2012-04-19T02:13:17+09:00 Subject: Why must I know whether I extend a class or a module? Hi. I have one module and one class. module Foo def test puts 'This is method test() from module Foo.' end end class Bar def test puts 'This is method test() from class Bar.' end end If I want to modify that at a later time, I need to do something like: module Foo def test puts 'Yes, still testing'. end end Or class Bar # etc.. My question is: - Why do I need to KNOW that it is a module or a class? Can't I simply say "I do not care what it is a class or a module, simply add this method to it."? I don't understand why I need to explicitely know that one is a module and the other is a class. Was there a reason this distinction was used? I don't have a good alternative though. I thought about: modify Bar modify Class but that would require a new keyword I suppose. And typing "modify" is also longer than typing class. So there is no real advantage. So my real question is not so much why things are the way they are or that I want a change (I don't think there is a good change for it, so the current way is probably good enough), but my question is: - Why are things this way? Does anyone know? PS: On the other hand, when we can god-patch a class or a module, and undo these changes, perhaps we could also overcome the separation between classes and modules when I want to modify their behaviour. From a design point of view, I dont really think it should be needed to know whether one modifies a module or a class. (Ruby's behaviour could be to first search for class, then for module.) -- Posted via http://www.ruby-forum.com/.