the_prole the_prole - 1 year ago 56
Ruby Question

`String.methods - Object.methods` does not show all String class methods

I have run the following command in

from Window's command console

String.methods - Object.methods

But I only get the following output

=> [:try_convert]

How can I show all methods of String Class?

Answer Source

You have somewhat misleading title, because if you want to get a list of

String class methods

then you are actually on the right track, because Object#methods returns a list of singleton methods.

But the documentation you have linked contains a list of instance methods, defined in String class.

To get this list, you want to use Module#instance_methods:

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download