Ruby equivalent of Python's “dir”?

后端 未结 9 1630
温柔的废话
温柔的废话 2020-12-23 16:09

In Python we can \"dir\" a module, like this:

>>> import re
>>> dir(re)

And it lists all functions in the module. Is ther

9条回答
  •  旧时难觅i
    2020-12-23 16:43

    Not really. Like the others said, you can get part of what you want by listing class instance methods (e.g. String.instance_methods) but that doesn't help you if a file you open reopens a class (unless you check before and after).

    If you don't need programmatic access to the list of methods, consider checking out the documentation for a class, module or method using the ri command line tool.

提交回复
热议问题