Get all local variables or available methods from irb?

前端 未结 3 1563
粉色の甜心
粉色の甜心 2021-02-12 09:44

When I go into irb and type in a command that does not exist I get an error stating

\"undefined local variable or method \'my_method\' for main:Object (NameError         


        
3条回答
  •  陌清茗
    陌清茗 (楼主)
    2021-02-12 10:12

    To find out instance variables, you can use Kernel#instance_variables as Zabba pointed out.

    For methods available on an object, I use my_object.methods - Object.methods to find out what non-obvious methods are available to my object. This narrows down the list and is considerably easy to read.

提交回复
热议问题