On Thu, 2025-02-20 at 09:57 -0800, cpu...@gmail.com wrote:
> Sorry for not finding a better than this click bait subject. 
> 
> In https://github.com/golang/go/issues/62642 this suggestion was
> made:
> 
> slices.SortFunc(times, time.Time.Compare)
> 
> It's totally unclear to me how Time.Compare matches the compare
> func(a,b T) int signature? I assume it's something from the golang
> spec, but which part?

In https://go.dev/ref/spec#Method_expressions

Function values derived from methods are called with function call
syntax; the receiver is provided as the first argument to the call.
That is, given f := T.Mv, f is invoked as f(t, 7) not t.f(7).


So https://pkg.go.dev/time#Time.Compare, func (t Time) Compare(u Time)
int, becomes time.Time.Compare(t, u Time) int.

-- 
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 visit 
https://groups.google.com/d/msgid/golang-nuts/be5f2a3a504346ddefda4bd2961c80daa604892b.camel%40kortschak.io.

Reply via email to