SUPPORT THE SITE WITH A CLICK

Subscribe Rss:

SUPPORT THE SITE WITH A CLICK

Tuesday, August 26, 2008

Method existing in Classes in ruby

Instance variables are hidden away inside the object. They’re not terribly hidden, you see them whenever you inspect the object, and there are other ways of accessing them, but Ruby uses the good object-oriented approach of keeping data sort-of hidden away.

So what methods do exist for Greeter objects?


irb(main):003:0> Greeter.instance_methods
=> ["method", "instance_variables", "__id__", "to_s", "send", "object_id", "dup", "private_methods", "=~", "is_a?", "class", "tainted?", "singleton_methods", "eql?", "untaint", "instance_of?", "id", "instance_variable_get", "inspect", "instance_eval", "extend", "nil?", "__send__", "frozen?", "taint", "instance_variable_defined?", "public_methods", "hash", "to_a", "clone", "protected_methods", "respond_to?", "display", "freeze", "kind_of?", "==", "instance_variable_set", "type", "===", "equal?", "methods"]
irb(main):004:0>

No comments :

Post a Comment