Missing syntax? comparable receiver

I was doing the Tour of Go, and got to generic/2
I wanted to write a delete method, and found that I needed T to be comparable.
Then I tried the following syntax:

func (l *List[T comparable]) delete(t T) bool

but found that it is not legal, so that I could only produce:

func delete[T comparable](l *List[T], t T) bool

Any reason why my intention would be ‘wrong’?
Any pending attempt to support something similar?

1 Like

Ahum… My colleague corrected me with the obvious and elegant solution:

type List[T comparable] struct {
	next *List[T]
	val  T
func (l *List[T]) delete(t T) bool {

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.