in reply to Refactoring: dumb or witty use of ternary operator?
Or am I overseeing some "important" side effect?
Probably a warnings freak like me :)My guess is that the keys aren't known until the script is run, and that's your colleague's way of getting rid of the warnings. A perfectly valid way too. They are making you explicitly aware of the fact that $outhash{$str} may be undefined when you try to increment it.
This would work equally well:
$outhash{$str}||=0; $outhash{$str}++;
.02
cLive ;-)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Refactoring: dumb or witty use of ternary operator?
by Abigail-II (Bishop) on Jun 22, 2004 at 10:06 UTC | |
by cLive ;-) (Prior) on Jun 22, 2004 at 17:54 UTC | |
|
Re^2: Refactoring: dumb or witty use of ternary operator?
by diotalevi (Canon) on Jun 22, 2004 at 18:32 UTC | |
|
Re^2: Refactoring: dumb or witty use of ternary operator?
by PetaMem (Priest) on Jun 22, 2004 at 06:54 UTC | |
by cLive ;-) (Prior) on Jun 22, 2004 at 08:12 UTC | |
by revdiablo (Prior) on Jun 22, 2004 at 07:07 UTC |