Interfaces are not equal: "m2() aer" and "m2() ber" has different return type. Even compiler told you about it. On Monday, May 24, 2021 at 9:20:51 AM UTC+3 Amnon wrote:
> See https://play.golang.org/p/5x9JrD55WKc > > The interfaces aer and ber look equivalent. > Both contain a function which returns nothing called m1 > and a function which returns another an instance of the interface m2. > > If we comment out m2, then the code will compile. > But otherwise we get an error: > > ./prog.go:14:5: cannot use a (type aer) as type ber in argument to bar: > aer does not implement ber (wrong type for m2 method) have m2() aer want > m2() ber > > even though aer and ber should be equivalent! > > package main > > type aer interface { > m1() > m2() aer > } > > type ber interface { > m1() > m2() ber > } > > func Foo(a aer) { > bar(a) > } > > func bar(b ber) { > } > > func main() { > } > > -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/af7f3062-f871-491f-9130-e4d77d9ae25dn%40googlegroups.com.