go - Using an operator in place of a function -
Is it possible to use an operator in a function?
For example, in +
?
The following code is possible to replace the addition
with the package main import "fmt" var cur, prev int = 1? 1 func fib (f func (int, int) int) int {return f (cur, prev)} func main () {add: = func (x int, y int) int {return x + y}; Fmt.Println (Fib (add)}}
If it is not possible to use the operator as a function, then I appreciate a link to the documents that explain it.
Operator go (or mostly in other languages) do not have first-class values, therefore, not Can not give them as arguments Notice that uses func (x, y int) int {return x + y}
in its examples.
Also keep in mind that the operator has no choice but to operate without a similar expression.
Comments
Post a Comment