See "Method expressions" in the Go Programming Language Specification.


On Thursday, February 20, 2025 at 10:30:22 AM UTC-8 Mike Schilling wrote:

> Any method can be called as a normal function with the receiver as the 
> first argument. Thus you can call time.Time.Compare(time1, time2) . 
> On Thursday, February 20, 2025 at 9:57:35 AM UTC-8 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?
>>
>> Are there other typical uses of this capability that are common?
>>
>> Cheers,
>> Andi
>>
>

-- 
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/01b2dfbb-c67b-4b09-b380-57ea6bacb731n%40googlegroups.com.

Reply via email to