SPUG: method call during object construction

Umar Cheema umar at drizzle.com
Wed Feb 15 15:16:32 PST 2006

Okay nevermind, I see it now. It's a simple assignment. $obj gets set 
to the value that's returned by the method call or by the last assignment 
inside the method.

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');

But after the constructor call $obj simply holds the value returned by the 
'change_name' method.

Of course the following works just fine:

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

Can someone explain what is going on with the first way of calling a 
method during construction? Is this something we're not suppose to do or 
am I just seeing weird perl behavior for some other reason?


Seattle Perl Users Group Mailing List  
     POST TO: spug-list at pm.org
SUBSCRIPTION: http://mail.pm.org/mailman/listinfo/spug-list
    MEETINGS: 3rd Tuesdays
    WEB PAGE: http://seattleperl.org/

More information about the spug-list mailing list