in reply to Re^2: [Perl 6] $ and @ - what is it coming to?
in thread [Perl 6] $ and @ - what is it coming to?
As best I understand it, because in Perl 6, arrays always use the '@' sigil.
So elements of @x are accessed using @x[1]
And elements of the array pointed at by $x can be accessed using $x[1].
The abiguity that is confusing you is because Perl 5 used $x[1] to access elements of array @x.
@x = ( 1, 2, 3);; print @x[1];; Scalar value @x[1] better written as $x[1] at 2
The explanation for that was that the use of the '$' signified that the element accessed was a scalar. But elements of arrays are always scalars, which makes the purpose of changing the sigil redundant. So in Perl 6 you don't.
In the same way, if it hasn't changed since I last looked, hash elements are addressed using %x{'foo'} (or %x<foo>) and not $x{'foo'} as now.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: [Perl 6] $ and @ - what is it coming to?
by ruzam (Curate) on Mar 26, 2008 at 19:16 UTC | |
by chromatic (Archbishop) on Mar 26, 2008 at 23:48 UTC | |
|
Re^4: [Perl 6] $ and @ - what is it coming to?
by ruzam (Curate) on Mar 26, 2008 at 19:21 UTC | |
by BrowserUk (Patriarch) on Mar 26, 2008 at 19:34 UTC | |
by John M. Dlugosz (Monsignor) on Mar 27, 2008 at 04:30 UTC | |
by BrowserUk (Patriarch) on Mar 27, 2008 at 06:38 UTC | |
by John M. Dlugosz (Monsignor) on Mar 29, 2008 at 08:25 UTC |