in reply to Re: Re: correct usage of class attributes
in thread correct usage of class attributes
You don't have to declare them. Simply assigning to $self->{height} will do the trick. After all, the object is just a Perl hash that is blessed, nothing more.
Of course, you may want to initialize the object attributes to default values so that you know their state. In that case the constructor is a good place to do so (the class method conventionally called new.
Note that this is just the simplest approach to objects in Perl and definitely not the cleanest of safest, but well, it's good to start with IMHO.
Hope this helps, -gjb-
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Re: Re: correct usage of class attributes
by Anonymous Monk on May 05, 2004 at 14:26 UTC | |
by gjb (Vicar) on May 05, 2004 at 15:02 UTC |