1个回答
展开全部
有一个叫methods()的方法,比如Array.methods()
--------------------------------------------------------- Object#methods
obj.methods => array
------------------------------------------------------------------------
Returns a list of the names of methods publicly accessible in
_obj_. This will include all the methods accessible in _obj_'s
ancestors.
class Klass
def kMethod()
end
end
k = Klass.new
k.methods[0..9] #=> ["kMethod", "freeze", "nil?", "is_a?",
"class", "instance_variable_set",
"methods", "extend", "<em>send</em>", "instance
_eval"]
k.methods.length #=> 42
--------------------------------------------------------- Object#methods
obj.methods => array
------------------------------------------------------------------------
Returns a list of the names of methods publicly accessible in
_obj_. This will include all the methods accessible in _obj_'s
ancestors.
class Klass
def kMethod()
end
end
k = Klass.new
k.methods[0..9] #=> ["kMethod", "freeze", "nil?", "is_a?",
"class", "instance_variable_set",
"methods", "extend", "<em>send</em>", "instance
_eval"]
k.methods.length #=> 42
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询