zlox/samples/ch25_closures2.lox

22 lines
346 B
Plaintext
Raw Permalink Normal View History

2024-08-29 10:54:03 +02:00
fun makeClosure() {
var local = "local";
fun closure() {
print local;
}
return closure;
}
var closure = makeClosure();
closure();
fun makeClosure2(value) {
fun closure() {
print value;
}
return closure;
}
var doughnut = makeClosure("doughnut");
var bagel = makeClosure("bagel");
doughnut();
bagel();