-
Notifications
You must be signed in to change notification settings - Fork 18.8k
Closed
Labels
Milestone
Description
Proposal Details
I find myself writing this a lot lately. Sometimes multiple times in a module because I don't want to export it or bother with creating internal/ packages just for this.
package cmp
func Equal[T comparable](a, b T) bool {
return a == b
}This comes up whenever you have Op and OpFunc where the latter variant takes an equality function. The body of Op just calls OpFunc with some local copy of the proposed.
Even with the shortest possible syntax proposed in #21498 this would still be (a, b) => a == b vs cmp.Equal[T] and T would often be inferred as this is basically always used as the argument to a function.
Reactions are currently unavailable