in reply to Re: What means: "bless { @_ } => $class;"?
in thread What means: "bless { @_ } => $class;"?
The return value of the sub is the last eval:ed statement, in this case the 'bless'. It returns the reference (new object).
It is a common idiom to place the bless last in 'new' methods, so the new object is returned.
(The one asking the question probably knows this, since it says so in the Camel book about 'bless'. But just to be safe.. the other part of the question is almost there in the Camel book, too.)
Update:
Surprising, but if merlyn says it is a pedagogical problem, I'll believe it. :-) (That would be Perl-only programmers? The "return last value by default" is quite Perl-specific, afaik?)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: What means: "bless { @_ } => $class;"?
by merlyn (Sage) on Apr 24, 2006 at 13:12 UTC |