-
Notifications
You must be signed in to change notification settings - Fork 11
Functions
Chase Willden edited this page May 5, 2016
·
2 revisions
Functions are declared using the following syntax:
func getName(int a, double b, string c, var d){
}
Functions may be overloaded:
func getValue(int b){
return b;
}
func getValue(double b){
return b;
}
If the parameter uses the var
type, then this will be the last overloaded function.
func getValue(var b){
return b;
}
Functions may be nested inside of functions. Where a body of code is, a function may be declared. For example:
func test(){
func test1(){
func test2(){
return 1;
}
return test2();
}
return test1();
}
Functions may have default arguments.
func defaultArgs(int a = 10){
println(a);
}
defaultArgs();