On Tue, Jan 19, 2021 at 7:06 PM burak serdar <bser...@computer.org> wrote:
> However, there is no way for P to check if x is nil. This does not compile: > > func P[T fmt.Stringer](x T) { > if x!=nil { > fmt.Println(x) > } > } Is this doing what you want? func P[T fmt.Stringer](x T) { if fmt.Stringer(x)!=nil { fmt.Println(x) } } https://go2goplay.golang.org/p/7S4RX5G3rT_3 -- 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 on the web visit https://groups.google.com/d/msgid/golang-nuts/CAADvV_t6iLQUurV7Gor%2BMmyOPdh25218wxSEnyTihc-kB%2BmvvA%40mail.gmail.com.