Generic typedef indirect is not supported

consider this code, the function Init is not recognized
There is no way to simplify type definition like in other language (c++)

type List[T any] struct {
	next *List[T] 
	val  T
}


func (o *List[T]) Init(a int){
	fmt.Printf(" %+v %v",*o,a)
	
}


type list8 List[uint8]

func main() {
	var a list8
	a.val = 12

	a.Init(17)
}

Try

type list8 = List[uint8]

Thanks, now I see in the spec that there are two ways to define a type
alias and new type

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