[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Re: Get only the non-inherited methods of a class

Yukihiro Matsumoto

11/2/2007 2:00:00 PM

Hi,

In message "Re: Get only the non-inherited methods of a class"
on Fri, 2 Nov 2007 22:29:15 +0900, Max Williams <toastkid.williams@gmail.com> writes:

|Thanks matz, but why does that return an empty array? Shouldn't it be
|
|["%", "*", "+", "<<", etc]?
|
|(actually for me it returns ["yaml_new", "yaml_tag_subclasses?"], each
|of which gives me a NoMethodError when i try to call it on a string)

I thought you want class methods of String class. If you want to get
instance_methods of a class C, call

C.instance_methods(false)

|Would you mind explaining what passing false to methods does?

It means to list methods defined in the particular class.

matz.

1 Answer

Max Williams

11/2/2007 2:07:00 PM

0

Yukihiro Matsumoto wrote:

>
> I thought you want class methods of String class. If you want to get
> instance_methods of a class C, call
>
> C.instance_methods(false)
>

Fantastic, thanks! And thanks for Ruby :D

--
Posted via http://www.ruby-....