32 lines
397 B
Plaintext
32 lines
397 B
Plaintext
//_d so the test doesn't run yet
|
|
|
|
// capturing closures in lists:
|
|
|
|
var f = funct() {
|
|
var y = 5;
|
|
var x = @[
|
|
funct() print y,
|
|
funct() y = y + 1
|
|
];
|
|
:result = x;
|
|
};
|
|
|
|
//expect:5.0
|
|
f()[0]();
|
|
f()[1]();
|
|
//expect:6.0
|
|
f()[0]();
|
|
|
|
// capturing the result of a function:
|
|
|
|
var f2 = funct() {
|
|
var x = { @f2
|
|
:result = funct() {
|
|
print :f2;
|
|
};
|
|
};
|
|
x = 5;
|
|
};
|
|
|
|
//expect:5.0
|
|
f2()(); |