The way to Return Lambda Features in Golang
Go doesn’t usually have Lambda Expressions, however synonymous to Lambdas
, or Closures
if Nameless Features
for Go.
The way to return a worth from an Nameless Operate in Go#
package deal predominant
import "fmt"
func predominant() {
var sum = func(n1, n2 int) int {
sum := n1 + n2
return sum
}
end result := sum(5, 3)
fmt.Println("Sum is:", end result)
}
The way to return an Space from an Nameless Operate in Go#
package deal predominant
import "fmt"
var (
space = func(l int, b int) int {
return l * b
}
)
func predominant() {
fmt.Println(space(10, 10))
}