On Jun 19, 2013, at 12:34 PM, Philippe de Rochambeau (via RT) 
<perl6-bugs-follo...@perl.org> wrote:
> # New Ticket Created by  Philippe de Rochambeau 
> # Please include the string:  [perl #118541]
> # in the subject line of all future correspondence about this issue. 
> # <URL: https://rt.perl.org:443/rt3/Ticket/Display.html?id=118541 >
> 
> 
> 
> Hello,
> 
> according to http://en.wikibooks.org/wiki/Perl_6_Programming/Types_and_Context
> 
> the following statement is supposed to set $z to 3
> 
> my $z = $(2..4);              # Three elements, becomes the number 3
> 
> In Rakudo Perl 2013.5 on Windows 7, 2..4 is returned instead
> 
> perl6 -e "my $z = $(2..4); say $z"
> 2..4

The $() provides item context to the range.  As much as the my $z = does.  So 
in effect, this is really the same as:

   my $z = 2..4

And that is a range, as observable here:

$perl6 -e 'my $z = 2..4; say $z.WHAT'
(Range)

I think the example:

  my $z = $(2..4);              # Three elements, becomes the number 3

is incorrect.  If you really would like to see the number of elements, use the 
.elems method:

$ perl6 -e 'my $z = (2..4).elems; say $z'
3


Hope this helps.



Liz

Reply via email to