// ... imagine some comparison sort algorithm func cmpSort[C Cmpable](x []C) { for i, val := range x { if i == 0 { continue } _ = val.Cmp(x[i-1]) } }
// Cmpable should include big.Int, big.Float, big.Rat, by virtue of their Cmp methods. So how do i define this better? type Cmpable interface { Cmp(other any) int } // TODO: how do i replace "any" with "this type". "Cmpable" doesn't work as that would be any Cmpable, not THIS Cmpable. -- 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/4f167deb-bf63-43db-9ec9-c4c451c14d09n%40googlegroups.com.