To me it's perfectly clear why those two behave differently: shift() returns a scalar, splice() returns a list.
Putting a function that is "scalar context only" in a list context will give you a list with one element. No special magic to (surprisingly) return an empty list here.
Many builtins have list context semantics, but for shift() I'd have no idea what would make sense. Although a "shift ARRAY, COUNT" semantics might be handy sometimes. But even then I'd expect shift to always return exactly COUNT elements, even if ARRAY was empty.
In reply to Re: shift in list context buggy?
by Beechbone
in thread shift in list context buggy?
by LanX
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |