in reply to Ternary Quizical behaviour?
needlessly superfulous and relies on a side effect I'm a little wary of; do:'b' => exists($tests{'b'}) && defined($m=$tests{'b'}) ? $m : 0,
But since the default is 0, this should mitigate the need for defined:'b' => (defined $tests{'b'}) ? $tests{'b'} : 0,
b => $tests{b} // 0,
Also, defined($m=$tests{'b'}) smells a little funny; I get what you're doing but it is unnecessary.
Update - I am confused but the need for $m. It's getting set twice in your original code, both times based on the state of $tests{'b'}, then you set it to 10. What are you trying to do? Is this your real code or a contrived example?
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: Ternary Quizical behaviour?
by Eily (Monsignor) on Jul 10, 2020 at 12:40 UTC | |
by perlfan (Vicar) on Jul 10, 2020 at 20:44 UTC |
In Section
Seekers of Perl Wisdom