On 28 February 2016 at 21:59, rakesh sharma <[email protected]> wrote:
> According to docs bless returns the reference to self.
That just means that if you do:
my $x = {};
my $y = bless $x, "THING";
$y and $x will both be the same thing, a {} blessed into "Thing"
Its just more convenient to utilize the second of these because its simpler:
sub new {
...
my $x = {};
bless $x, $class;
return $x;
}
^ works, but its just ugly when you can do
sub new {
...
return bless {}, $class;
}
--
Kent
KENTNL - https://metacpan.org/author/KENTNL
--
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
http://learn.perl.org/