# Method\_defined? does what exactly?

**URL:** <https://www.ruby-forum.com/t/method-defined-does-what-exactly/189650>\
**Category:** Ruby\
**Created:** [June 4, 2010, 1:28pm UTC](https://www.ruby-forum.com/t/method-defined-does-what-exactly/189650 "2010-06-04T13:28:01Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![tcsnide](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/eb8c5e/32.png) [@tcsnide](https://www.ruby-forum.com/u/tcsnide)\
**Post date:** [June 4, 2010, 1:28pm UTC](https://www.ruby-forum.com/t/method-defined-does-what-exactly/189650/1 "2010-06-04T13:28:01Z")

</div>

Ruby 1.9.2-head

p require\_relative(‘foo’)

module Kernel  
p method\_defined?(:require\_relative)  
end

produces

true  
false

Huh?

---

<div class="post-metadata">

**Author:** ![tcsnide](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/eb8c5e/32.png) [@tcsnide](https://www.ruby-forum.com/u/tcsnide)\
**Post date:** [June 4, 2010, 2:04pm UTC](https://www.ruby-forum.com/t/method-defined-does-what-exactly/189650/2 "2010-06-04T14:04:55Z")

</div>

Hmm maybe I was not very clear in my last post 😉

require\_relative is defined in Object

ruby -ve ‘p method( :require\_relative)’  
ruby 1.9.1p378 (2010-01-10 revision 26273) [i686-linux]  
#\<Method: Object#require\_relative\>

ruby -ve ‘p Object.method( :require\_relative )’  
ruby 1.9.1p378 (2010-01-10 revision 26273) [i686-linux]  
#\<Method: Class(Object)#require\_relative\>

However

ruby -ve ‘p Object.methods.grep( /require/ )’  
ruby 1.9.1p378 (2010-01-10 revision 26273) [i686-linux]  
[]  
^^^^ ???

Maybe a tiny bug here?

Cheers  
R.

---

<div class="post-metadata">

**Author:** ![tcsnide](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/eb8c5e/32.png) [@tcsnide](https://www.ruby-forum.com/u/tcsnide)\
**Post date:** [June 4, 2010, 2:01pm UTC](https://www.ruby-forum.com/t/method-defined-does-what-exactly/189650/3 "2010-06-04T14:01:59Z")

</div>

On Fri, Jun 4, 2010 at 1:27 PM, Intransition [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

---

<div class="post-metadata">

**Author:** ![tcsnide](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/eb8c5e/32.png) [@tcsnide](https://www.ruby-forum.com/u/tcsnide)\
**Post date:** [June 4, 2010, 2:18pm UTC](https://www.ruby-forum.com/t/method-defined-does-what-exactly/189650/4 "2010-06-04T14:18:58Z")

</div>

On Jun 4, 2010, at 8:04 AM, Robert D. wrote:

> #\<Method: Class(Object)#require\_relative\>  
> Cheers  
> R.
> 
> –  
> The best way to predict the future is to invent it.  
> – Alan Kay

No bug (in Ruby). The method is private.

$ ruby -ve ‘p Object.private\_instance\_methods.select{|m| m.to\_s =~ /  
require/ }’  
ruby 1.9.1p378 (2010-01-10 revision 26273) [i386-darwin9.8.0]  
[:require\_relative, :require]

-Rob

Rob B.  
[http://agileconsultingllc.com](http://agileconsultingllc.com)  
removed\_email\_address@domain.invalid

> **[Launch Scout Custom Software Development & Software Consulting](https://launchscout.com/)**
>
> We solve digital problems through custom software development and design for the web—apps, mobile, desktop and devices.

removed\_email\_address@domain.invalid

---

<div class="post-metadata">

**Author:** ![tcsnide](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/eb8c5e/32.png) [@tcsnide](https://www.ruby-forum.com/u/tcsnide)\
**Post date:** [June 4, 2010, 3:24pm UTC](https://www.ruby-forum.com/t/method-defined-does-what-exactly/189650/5 "2010-06-04T15:24:31Z")

</div>

On Jun 4, 8:18 am, Rob B. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> No bug (in Ruby). The method is private.

Damn it! I can’t tell you how many time I’ve been bitten by that.  
There REALLY needs to be a convenient way to check ALL methods,  
public, private and protected.

Of course I’ve said this the last time this came up too, but you know,  
who cares. Array#repeated\_permutation is much more important.

---

<div class="post-metadata">

**Author:** ![tcsnide](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/eb8c5e/32.png) [@tcsnide](https://www.ruby-forum.com/u/tcsnide)\
**Post date:** [June 4, 2010, 3:43pm UTC](https://www.ruby-forum.com/t/method-defined-does-what-exactly/189650/6 "2010-06-04T15:43:16Z")

</div>

On Fri, Jun 4, 2010 at 3:24 PM, Intransition [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> On Jun 4, 8:18 am, Rob B. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:
> 
> > No bug (in Ruby). The method is private.
> 
> Damn it! I can’t tell you how many time I’ve been bitten by that.  
> There REALLY needs to be a convenient way to check ALL methods,  
> public, private and protected.
> 
> Of course I’ve said this the last time this came up too, but you know,  
> who cares. Array#repeated\_permutation is much more important.

I agree with you and I would like to add that #method returns all  
kind of methods and there is no method #private\_method.  
Would be too nice to have  
#method(s), #private\_method(s), #public\_method(s) and  
#protected\_method(s)  
shrug.

Consistency does not seem to be important to most, I have made this  
experience before, and that has to be accepted ☹

R.

---

<div class="post-metadata">

**Author:** ![tcsnide](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/eb8c5e/32.png) [@tcsnide](https://www.ruby-forum.com/u/tcsnide)\
**Post date:** [June 5, 2010, 6:43am UTC](https://www.ruby-forum.com/t/method-defined-does-what-exactly/189650/7 "2010-06-05T06:43:07Z")

</div>

On Jun 4, 9:42 am, Robert D. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> experience before, and that has to be accepted ☹  
> Oh, and one more thing.

a.product(a) == a.repeated\_permutation(2).to\_a  
a.product(a,a) == a.repeated\_permutation(3).to\_a  
a.product(a,a,a) == a.repeated\_permutation(4).to\_a  
…

---

<div class="post-metadata">

**Author:** ![tcsnide](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/eb8c5e/32.png) [@tcsnide](https://www.ruby-forum.com/u/tcsnide)\
**Post date:** [June 5, 2010, 6:36am UTC](https://www.ruby-forum.com/t/method-defined-does-what-exactly/189650/8 "2010-06-05T06:36:01Z")

</div>

On Jun 4, 9:42 am, Robert D. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> I agree with you and I would like to add that #method returns all  
> kind of methods and there is no method #private\_method.  
> Would be too nice to have  
> #method(s), #private\_method(s), #public\_method(s) and #protected\_method(s)  
> shrug.
> 
> Consistency does not seem to be important to most, I have made this  
> experience before, and that has to be accepted ☹

I think it is more than that. I don’t see much evidence that there is  
a great deal of consideration going into these additions at all. I  
watched Dave T.'s “Ruby Sucks” talk yesterday, and he tried to  
paint a rosy picture around the whole thing. I agree with him to the  
extent that its cool that ruby is so flexible, but when he mentioned  
how they just throw methods in there, “Is it useful? Well I used it  
once. Okay!” That just struck a bad nerve. I do not see a whole lot of  
rational for what is getting into the language. But it’s also not just  
stuff getting thrown in there. It’s clearly selective, but on some  
esoteric, perhaps nepotist, or maybe it’s as simple as a C coders  
clique making all the choices --actually I do think that is part of  
the problem. The people who write Ruby are first and foremost C  
coders, not Ruby programmers. I think most of them use Ruby like  
others use Perl --as an admin and tools language; as opposed to an  
applications framework. Of course, I don’t know the actual reasons,  
but clearly something must explain it --I could easily name a dozen  
widely used extensions off the top of my head that make most of  
1.9.2’s new methods look absolutely lonely.

I think if there were a rational process of determining what would be  
best to add to the language, it would be a careful cross-comparison of  
the most popular gems out there today. Look at they have common, the  
methods, idioms and patterns. Then figure out the best way to support  
these things in Ruby proper to the benefit them all.

trans.
