Thanks El mar, 6 feb 2024 a las 12:05, Ian Lance Taylor (<i...@golang.org>) escribió:
> On Tue, Feb 6, 2024 at 6:43 AM Victor Manuel “Vitu” Giordano > <vitucho3...@gmail.com> wrote: > > > > I'm wondering why the language allow me to write something like this: > > > > type IncFunc func(a int) int > > > > type Incrementor interface { > > IncFunc // <-- THIS is allowed > > IncQuantity() int > > } > > > > (RTR example here) > > > > I don't get how I can make leverage of that.. or if has any sense at all > 🥴😵💫 > > As I recall an interface is a set of methods, and a method do have a > name... the thing here is that the name if the name of the type not the > function's name. > > An interface type like that can be used as a constraint for a type > parameter. It can't be used as the type of a variable. As a type > parameter constraint it means that the type argument must be IncFunc. > It's fairly useless, but follows from the other rules about type > parameter constraints. > > Ian > -- V -- 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/CAPUu9ssWofyST_KX3htbcR4aN09gi6MTr%2B9kBxmXaFEiFG6T2A%40mail.gmail.com.