Go Concepts - Functions: Difference between revisions

From NovaOrdis Knowledge Base
Jump to navigation Jump to search
Line 37: Line 37:


{|
{|
| [[go Built-In Function make|make()]] || [[go Built-In Function append|append()]] || [[go Built-In Function copy|copy()]] || . || .
| [[go Built-In Function make|make()]] || [[go Built-In Function append|append()]] || [[go Built-In Function copy|copy()]] || [[go Built-In Function delete|delete()]] || .
|-
|-
|  [[go Built-In Function new|new()]] || [[go Built-In Function len|len()]] || [[go Built-In Function cap|cap()]]  || . || .
|  [[go Built-In Function new|new()]] || [[go Built-In Function len|len()]] || [[go Built-In Function cap|cap()]]  || . || .

Revision as of 16:38, 18 March 2016

External

Internal

Overview

Syntax

func [value-receiver] <name>([parameter-identifier1] [type1], [parameter-identifier2] [type2], ...) ([return-type1], [return-type2], ...) {

   statement1
   statemen2
   ...

   return <return-value1>, <return-value2>

}

Examples:

func add(a int, b int) (int) {
   return a + b;
}

Value Receiver

Built-in Functions

make() append() copy() delete() .
new() len() cap() . .
. . . . .

Closures

Anonymous function that capture local variables.

More about closures is available here.