From: Logan Capaldo Date: 2006-12-17T07:09:08+09:00 Subject: Re: Why is define_method private? Plus, what's the point of private methods? On Fri, Dec 15, 2006 at 09:59:50AM +0900, Daniel Finnie wrote: > Why is define_method a private method? I can't recall ever using > define_method on the class I was working in, only using > class.send(:define_method).... > > Personally, I find that the following: > Class.define_method(:foo, &myBlock) > > is much cleaner than this: > Class.send(:define_method, :foo, &myBlock) > > What are the advantages to having define_method be private? Are there > any cons to having it public? I can find one con to having it private > and no pros, which leads my to my main question...why is it private? > Well a class should control it's own methods, just saying Class.define_method ... without any context looks dangerous. (Using send even more so). Obviously it is there to be used, but I think the assumption is that you do this: Class.class_eval do define_method(:foo) { ... } ... end It looks more like class Class def foo ... end end that way anyway.