in reply to bless with => separated args
Does anyone know of any reason why => might be used in place of , in this instance?There's no particular reason apart readability/psychological feeling. Here you have a large structure applied -this is the keyword!- by bless to the class you want to bless it into. You often use => instead of , when you want to stress that the term on the left is applied or associated to that on the right.
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!Indeed it stringifies only in a few situations and in some cases this has led to confusion.
Incidentally, it may be a matter of personal preference/style, but this:
is deprecated by many kwnoledgeable OO Perl hackers.return bless my $self = {}, (ref $class || $class); # ^^^^^^^^^^^^^^^^^^^^^^
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: bless with => separated args
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 Anonymous Monk on Aug 01, 2005 at 12:02 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 |