jaa has asked for the wisdom of the Perl Monks concerning the following question:
My question is about the use of the => comma like operator.package Some_Class; our($CData1, $CData2); sub new { my $obclass = shift; return bless my $self = { ObData1 => "", ObData2 => "", CData1 => \$CData1, CData2 => \$CData2, } => (ref $obclass || $obclass); }
Why?
seems to work just as well.sub new { my $class = shift; return bless my $self = {}, (ref $class || $class); }
Does anyone know of any reason why => might be used in place of , in this instance?
Interestingly, this has let to a clarification on the meaning of => for me.
I had always assumed that => stringifies its left operand, but a little testing, seems to indicate it only actually stringifies if it thinks the left operand is a word... i.e. not a $var - subtle!
Regards,
Jeff
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: bless with => separated args
by blazar (Canon) on Aug 01, 2005 at 08:49 UTC | |
by jaa (Friar) on Aug 01, 2005 at 09:32 UTC | |
by davorg (Chancellor) on Aug 01, 2005 at 09:42 UTC | |
by Anonymous Monk on Aug 01, 2005 at 11:04 UTC | |
by davorg (Chancellor) on Aug 01, 2005 at 11:14 UTC | |
| |
by blazar (Canon) on Aug 01, 2005 at 09:58 UTC | |
by Anonymous Monk on Aug 01, 2005 at 11:07 UTC | |
by Anonymous Monk on Aug 01, 2005 at 10:56 UTC | |
|
Re: bless with => separated args
by davorg (Chancellor) on Aug 01, 2005 at 09:06 UTC | |
|
Re: bless with => separated args
by jaa (Friar) on Aug 01, 2005 at 08:45 UTC | |
|
Re: bless with => separated args
by Anonymous Monk on Aug 01, 2005 at 10:49 UTC |