The ability to define an anonymous implementation of an interface using anonymous functions, similar to the pseudo code:
RandomNumOp({ Binary: func(a,b int) int { return a b}, Ternary: func(a,b,c int) int {return a b c}, })
is not directly supported in Go. Here are some possible approaches, depending on whether the implementation is required to work:
Disclaimer: All resources provided are partly from the Internet. If there is any infringement of your copyright or other rights and interests, please explain the detailed reasons and provide proof of copyright or rights and interests and then send it to the email: [email protected] We will handle it for you as soon as possible.
Copyright© 2022 湘ICP备2022001581号-3