"be consistent" | |
PerlMonks |
Re^4: Array slices: beyond the end/ Assigning an empty list to a Hash sliceby 7stud (Deacon) |
on Mar 22, 2014 at 19:23 UTC ( [id://1079401]=note: print w/replies, xml ) | Need Help?? |
It is the simplest way to distinguish between a slice from an empty list and a slice of a list of undefs. The former is FALSE, the latter is TRUE in a test. Okay.The slice returns you exactly the number of elements you asked it to return, not some unexpected or unpredictable smaller number. False. You do get a smaller number of elements, i.e. 0, when all the slice indexes are beyond the end...as you pointed out:
...UNLESS the whole slice would have to be padded with undefs, in which case you get an empty list So I think your first point is the only valid reason.
In Section
Seekers of Perl Wisdom
|
|