Function
without name is called anonymous function.
Example
add :=
func(a int, b int) int{
return a + b
}
HelloWorld.go
package main import "fmt" func main() { add := func(a int, b int) int{ return a + b } result := add(10, 20) fmt.Println("result : ", result) }
Output
result
: 30
No comments:
Post a Comment