here's an example more like my specific use case that i just mentioned, with the surprising inference behavior --- https://go.dev/play/p/BNmjlYejawZ
On Monday, June 20, 2022 at 9:21:34 AM UTC-4 Mike Andrews wrote: > great, thanks brian, works like a charm. surprisingly, even works in my > specific use case calling it like "interfaceFunc[T](x)" generically without > being specific like "[string]", wondering why the compiler's inference is > like that? is it a flaw or just a limitation of the concept per se? > > On Monday, June 20, 2022 at 8:44:06 AM UTC-4 Brian Candler wrote: > >> Type inference doesn't work in all cases. When required, just be >> explicit: >> >> interfaceFunc[string](x) >> >> https://go.dev/play/p/j66sXsfMUBl >> >> On Monday, 20 June 2022 at 13:06:57 UTC+1 Mike Andrews wrote: >> >>> anyone know why this simple case doesn't compile? i'm trying to call a >>> function defined for generic interface type, which fails to compile for >>> struct instance: https://go.dev/play/p/Y3Gdr2ILpK4 >>> >>> -- 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/ccfb056e-1336-474a-9f26-b2474270b72dn%40googlegroups.com.