# New Ticket Created by  Damian Conway 
# Please include the string:  [perl #122011]
# in the subject line of all future correspondence about this issue. 
# <URL: https://rt.perl.org/Ticket/Display.html?id=122011 >


The following test program demonstrates that, under Rakudo perl6 version
2014.04 built on MoarVM version 2014.04, a FIRST block is only called if
a loop block is actually executed, but a LAST block is called even the
block is skipped. This seems inconsistent and certainly makes FIRST/LAST
less useful. The behaviour of FIRST seems correct; the behaviour of LAST
seems wrong.

Specifically, I expected to get:

    {1, 2, 3, }

but I got:

    {1, 2, 3, }
    }

which seems to suggest LAST isn't quite right yet.

Damian

-----cut----------cut----------cut----------cut----------cut----------cut----------cut-----

use v6;

my @list;

@list = 1..3;
for (@list) -> $n {
    FIRST { print '{' }
    print "$n, ";
    LAST  { say '}' }
}

@list = ();
for (@list) -> $n {
    FIRST { print '{' }
    print "$n, ";
    LAST  { say '}' }
}

-----end----------end----------end----------end----------end----------end----------end-----

Reply via email to