I have run the following command in irb
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?
答案 0 :(得分:2)
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
:
String.instance_methods(false)
答案 1 :(得分:1)
p String.instance_methods(false)