in reply to Meaning of //
It's the only reason I switched my more complex software to 5.10 from 5.8 minimum requirement. It alleviates doing stuff like:
sub func { my ($thing) = @_; $thing = defined $thing ? $thing : 'non-thing'; # or if (defined $thing){ $thing = $thing; } else { $thing = 'non-thing'; } }
Much cleaner to use the previously-mentioned defined-or:
sub func { my ($thing) = @_; $thing //= 'non-thing'; }
That might not look like much of a difference, but add some complexity and other rules surrounding incoming variables and you can significantly reduce the keystrokes, code complexity and most important, readability, especially if in loop-type scenarios.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Meaning of //
by AnomalousMonk (Archbishop) on Oct 17, 2019 at 21:30 UTC |