in reply to Re: What is the difference between $array[1] and @array[1]?
in thread What is the difference between $array[1] and @array[1]?
(If you use slices with just one element you will get a warning though.)
That depends on how you write the slice:
Four one element slices, but only one warns.@a = (1 .. 5); say @a[1]; # Warning say @a[1..1]; # No warning say @a[1,]; # No warning @b = 1; say @a[@b]; # No warning
Frankly, I find the warning a bit silly; specially the warning if the slice is used in rvalue context. There isn't anything else the programmer could have reasonably meant. And in Perl6, @a[1] is going to be the required syntax anyway.
|
|---|