Re^2: Logical/defined or as lvalue
by NERDVANA (Priest) on Sep 03, 2024 at 21:13 UTC
|
We have ($w? $x : $y)= $z so why not? | [reply] [d/l] |
|
|
| [reply] [d/l] [select] |
|
|
My point was that if the ternary conditional is an lvalue, then I don't see why not to make the '||' and '//' operators lvalues. It would result in better consistency.
| [reply] |
|
|
| [reply] [d/l] [select] |
|
|
|
|
|
|
|
Many reasons why not. I already gave the two primary ones: lack of readability (due to its rare and unexpected use) and lack of usefulness.
If anything, I read your post as an argument against ( W ? X : Y ) = Z. But that has at least some modicum of usefulness.
| [reply] [d/l] |
Re^2: Logical/defined or as lvalue
by jo37 (Curate) on Sep 03, 2024 at 20:12 UTC
|
When would it be useful?
Consider items from @list to be counted, with one "given" set and a "rest".
A pre-initialized hash %h1 holds the "given" set and an empty hash %h2 counts the rest.
Then we could:
${\($h1{$_} // ($h2{$_} //= 0))}++ for @list;
Greetings, 🐻
$gryYup$d0ylprbpriprrYpkJl2xyl~rzg??P~5lp2hyl0p$
| [reply] [d/l] [select] |
|
|
If you're going to count them all, I don't see the point of having the counts split across two hashes. If there's an important distinction between the two sets of strings, you would need those lists, and you could access the counts of either lists.
| [reply] [d/l] [select] |
|
|
| [reply] |