Hello Everyone,
Pardon this newbie question.
What if the @ symbol is not used before creating new variable names
inside of methods?
Thanks,
Todd
then the variables are local to the method. @vars are always instance vars of
the object - they persist after the method invocation and are availble to any
method of the object. this analogy may help (although it is not really
correct):
- @vars are 'global' within an instance of a class - an object. all methods
of the object may see this variable and have unrestricted read/write
access to this @var. other objects of the same class have their own
unique copies of @vars however, and cannot see the @vars of other objects.
- @@vars are 'global' to all instances of a class. all objects of a given
class may see this variable. there is only one copy per class and all
objects of that class may read/write @@vars.
- 'normal' vars are just that, no special scoping rules, etc. they are
local to the method in which they were defined and leave scope (destroyed)
after the method has ended.
cheers.
-a
--
===============================================================================
| EMAIL :: Ara [dot] T [dot] Howard [at] noaa [dot] gov
| PHONE :: 303.497.6469
| A flower falls, even though we love it;
| and a weed grows, even though we do not love it.
| --Dogen
===============================================================================