mirror of
https://github.com/krgamestudios/Toy.git
synced 2026-04-15 23:04:08 +10:00
Functions take a set number of arguments
This commit is contained in:
@@ -1,51 +0,0 @@
|
||||
/*
|
||||
fn name(param1: string, param2: string, param3): string {
|
||||
print "foobar";
|
||||
print param1;
|
||||
return param2;
|
||||
}
|
||||
|
||||
var result = name("hello world", "goodnight world");
|
||||
|
||||
print "fizz";
|
||||
print result;
|
||||
print "buzz";
|
||||
|
||||
|
||||
*/
|
||||
|
||||
/*
|
||||
fn outer() {
|
||||
fn inner() {
|
||||
print "foo";
|
||||
}
|
||||
|
||||
inner();
|
||||
|
||||
return inner;
|
||||
}
|
||||
|
||||
var handle = outer();
|
||||
|
||||
handle(); //breaks
|
||||
*/
|
||||
|
||||
|
||||
fn make() {
|
||||
var counter = 0;
|
||||
|
||||
fn count() {
|
||||
return counter++;
|
||||
}
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
var tally = make();
|
||||
|
||||
print tally();
|
||||
print tally();
|
||||
print tally();
|
||||
print tally();
|
||||
print tally();
|
||||
|
||||
Reference in New Issue
Block a user