daveman has asked for the wisdom of the Perl Monks concerning the following question:
How do you add an element on to an array within a class. I have the following class
package MyClass;
my @fields;
sub new
{
my $this = {};
$this->{fields}=undef;
bless $this;
return $this;
}
sub addValue
{
push $this->{fields}, "some value";
}
I know this is the incorrect syntax because I am getting an error. Can you use the oush method to add an element? If not, what is the best way to do this?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: How do you add class array values
by tomhukins (Curate) on Apr 12, 2001 at 22:23 UTC | |
|
Re: How do you add class array values
by suaveant (Parson) on Apr 12, 2001 at 22:12 UTC | |
| A reply falls below the community's threshold of quality. You may see it by logging in. |