Introspection反射机制

# 這個物件有什麼方法
Object.methods
=> ["send", "name", "class_eval", "object_id", "new", "singleton_methods", ...]

# 這個物件有這個方法嗎?
Object.respond_to? :name
=> true

原文地址:https://www.cnblogs.com/qinyan20/p/4613602.html