package Foo;
my $i;
sub get { $i }
sub set { $i = shift; }
1
####
const subrefs = [];
let i = 0;
for ( let j = 3; j--; ) {
i++;
subrefs.push( function(){ console.log( i ); } );
}
for ( const subref of subrefs ) {
subref();
}
####
3
3
3
####
List subrefs = new();
int i = 0;
for (int j = 0; j < 3; ++j )
{
i++;
subrefs.Add( () => Console.WriteLine( i ) );
}
foreach ( var subref in subrefs ) {
subref();
}
####
3
3
3
####
subrefs = []
i = 0
for j in range(3):
i = i + 1
def subref():
print( i )
subrefs.append( subref )
for subref in subrefs:
subref()
####
3
3
3