Methods and Attributes
Throughout our discussion of objects and their contents, you may have been wondering, Method?
Dont worry about it.
You really dont need to know what a method is, or what the difference between a method and an attribute is, or whether something is one or the other. It really doesnt matter. All you need to know is what options are available to you at any given time. (And that methods and attributes are contained by objects, and so you must always specify the object first.)
But if youre really curious, the basic difference is that an attribute is a thing, and a method is a way of doing something. Attributes are nouns and methods are verbs. One clue that youre dealing with a method rather than an attribute would be the presence of parentheses, in which you supply the method with some additional information. For instance,
Value_at_time() is a method that returns the value of the specified property at the time specified in parentheses.
Entire contents © 2001 JJ Gifford.