If I have
type Foo struct {
// some data
}
func (f *Foo) Op1() bool {
// perform operation and return a bool
}
func (f *Foo) Op2(other int) bool {
// perform a different operation using internal data
// and the passed in parameter(s)
}
I know I can store a pointer to the first method.
fn := f.Op1
and call it
if fn(f) { // do something }
But what if I want to do the same with Op2?
I am currently faking it by defined a wrapper function which takes a Foo and the values and calls the operation. But that is a lot of boiler plate code.