R
Rainer Weikusat
The usual way to construct an instance of a Perl class (I'm aware of)
would look somewhat like this:
sub new
{
my ($class, $arg) = @_;
my $self;
$self->[0] = $arg;
return bless($self, $class);
}
Fairly recently, it occured to me that this can also be accomplished
with
sub new
{
my ($class, $arg) = @_;
my @self;
$self[0] = $arg;
return bless(\@self, $class);
}
Are there any good (or not-so-good) reasons to prefer one over the
other?
would look somewhat like this:
sub new
{
my ($class, $arg) = @_;
my $self;
$self->[0] = $arg;
return bless($self, $class);
}
Fairly recently, it occured to me that this can also be accomplished
with
sub new
{
my ($class, $arg) = @_;
my @self;
$self[0] = $arg;
return bless(\@self, $class);
}
Are there any good (or not-so-good) reasons to prefer one over the
other?