How do I introspect things in Ruby?

前端 未结 4 890
粉色の甜心
粉色の甜心 2021-01-31 18:57

For instance, in Python, I can do things like this if I want to get all attributes on an object:

>>> import sys
>>> dir(sys)
[\'__displayhook__         


        
4条回答
  •  猫巷女王i
    2021-01-31 19:02

    If you want all the methods that you can call on something than use

    >>> x.methods
    

    If you want some help information then call help before its class

    >>> help x.class
    

    Help is a wrapper for ri within irb.

提交回复
热议问题