SPUG: method call during object construction

Fred Morris m3047 at inwa.net
Wed Feb 15 15:20:11 PST 2006

Wild guess (since you didn't supply the actual code for the new() or
change_name() methods):

change_name returns 'new_class_name' as its function value.

On Wed, 15 Feb 2006, Umar Cheema wrote:

> I was hoping to make this work:
> my $obj = Class->new('class_name')->change_name('new_class_name');
> $obj->do_other_things();
> ....
> But after the constructor call $obj simply holds the value returned by the
> 'change_name' method.


my $obj;

($obj = Class->new('class_name'))->change_name('new_class_name');


Fred Morris

More information about the spug-list mailing list