Ruby Pocket Session # 1 - instance_methods
Posted by Massimo Sgrelli in
Ruby on Rails -
3 comments
Ruby is a wonderful object oriented programming language. The root class is Object which provides a set of very useful methods among which one called instance_methods. It returns an array with all the public methods of the class or the public methods of the module. Retuning an array you can apply normal array’s operators like this:
class Dog
attr :bark, true
end
irb> Dog.instance_methods - Object.instance_methods
irb> ["bark", "bark="]
(Ref. See Ruby Pocket Reference p. 38)


Comments
marktucks
Posted on March 03
marktucks
Posted on March 03
Massimo Sgrelli
Posted on March 03