in reply to shift in list context buggy?
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.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: shift in list context buggy?
by LanX (Saint) on Nov 12, 2013 at 14:14 UTC | |
by BrowserUk (Patriarch) on Nov 12, 2013 at 14:40 UTC | |
by LanX (Saint) on Nov 12, 2013 at 14:47 UTC | |
by BrowserUk (Patriarch) on Nov 12, 2013 at 15:24 UTC | |
by LanX (Saint) on Nov 12, 2013 at 15:33 UTC | |
| |
by Anonymous Monk on Nov 12, 2013 at 14:53 UTC | |
by LanX (Saint) on Nov 12, 2013 at 14:56 UTC | |
|