Skip to content
Chase Willden edited this page May 5, 2016 · 2 revisions

Syntax

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;
}

Nesting

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();
}

Default Arguments

Functions may have default arguments.

func defaultArgs(int a = 10){
   println(a);
}
defaultArgs();
Clone this wiki locally