Go Concepts - Functions: Difference between revisions
Jump to navigation
Jump to search
(→Syntax) |
(→Syntax) |
||
Line 12: | Line 12: | ||
<pre> | <pre> | ||
func [ | func [value-receiver] <name>([parameter-identifier1] [type1], [parameter-identifier2] [type2], ...) ([return-type1], [return-type2], ...) { | ||
statement1 | statement1 | ||
Line 31: | Line 31: | ||
} | } | ||
</pre> | </pre> | ||
=Value Receiver= | |||
=Built-in Functions= | =Built-in Functions= |
Revision as of 22:43, 17 March 2016
External
- Function type specification https://golang.org/ref/spec#Function_types
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
Closures
Anonymous function that capture local variables.
More about closures is available here.