SPUG:Object property question
Sanford Morton
smorton at pobox.com
Fri May 2 02:39:31 CDT 2003
Yes, you're right of course. To incorporate a constructor init method, which I
like, it ought to have been
sub new {
my $class = shift;
my $self = {};
bless $self, $class;
$self->_init (@_);
return $self;
}
On 2 May 2003, Michael R. Wolf wrote:
> Sanford Morton <smorton at pobox.com> writes:
>
> [...]
>
> > sub new { # constructor ==> changes and prints first name
> > my $class = shift;
> > my $self = {};
> > $self->_init(@_);
>
> NOPE!!!! Can't call a member method on an unblessed reference. Well,
> you can, but it doesn't do the magic of adding the referent as the
> first argument as you assume in the code below. But if you reshuffle
> the code, you could do it.
>
> > return bless $self, $class;
> > }
> >
More information about the spug-list
mailing list