go method
package main
import (
"fmt"
)
type Method interface {
tambah() int
}
type Math struct {
X, Y int
}
func (ctx *Math) tambah() int {
return ctx.X + ctx.Y
}
func tambah(ctx Method) int {
return ctx.tambah()
}
func main() {
ctx := &Math{20, 20}
result := tambah(ctx)
fmt.Println(result)
}