> -----Original Message-----
> From: raptor [mailto:[EMAIL PROTECTED]]
> Sent: Sunday, September 02, 2001 1:47 PM
> To: [EMAIL PROTECTED]
> Cc: [EMAIL PROTECTED]
> Subject: Re: LangSpec: Statements and Blocks [first,last]
>
>
> hi,
>
> As we read in Damian Conway- Perl6-notes, there will by a
> var-iterator that
> can be used to see how many times the cycle has been "traversed" i.e.
>
> foreach my $el (@ary) {
>    .. do something ....
>      print $#;  <--- print the index (or print $i )
> }
>
> shall we have :
>
> foreach my $el (@ary) {
>      print $# if $#.first();  <--- print the index on the first iteration

I personally don't like the .first() .last() method implementation, this
means we'll have .second .third, etc...  Why not just check the var iterator
$# == 0, means the first iteration, or have a special var that is not set to
the index, but rather the iteration number 1..end, in case the there is a
way to start iteration at different points.

Ilya


> i.e. 1
>    .. do something ....
>      print $# if $#.last();  <--- print the index on the first iteration
> i.e. $#ary
> };
>
> note : we can iterate on something else not only array
> OR :
>
> foreach my $el (@ary) {
>      print $# if first;
>    .. do something ....
>      print $# if latest;
> };
>
>
> =====
> iVAN
> [EMAIL PROTECTED]
> =====
> PS. One place where TT is before Perl :")
>

Reply via email to