Functions 10
This commit is contained in:
parent
7f4946f1e9
commit
e9e3c992cb
4 changed files with 20 additions and 2 deletions
13
test/closure.lox
Normal file
13
test/closure.lox
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
|
||||
fun makeCounter(){
|
||||
var i = 0;
|
||||
fun counter(){
|
||||
return i = i + 1;
|
||||
}
|
||||
return counter;
|
||||
}
|
||||
|
||||
var counter = makeCounter();
|
||||
print counter(); // "1".
|
||||
print counter(); // "2".
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue