From e0721dde050cac7142b9742cdefb09c69711db84 Mon Sep 17 00:00:00 2001 From: machangxin Date: Sat, 17 Dec 2022 14:59:21 +0800 Subject: [PATCH] function PrintSlice supports Generics --- codes/go/pkg/print_utils.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/codes/go/pkg/print_utils.go b/codes/go/pkg/print_utils.go index 3d9b83a29..a42d48b2f 100644 --- a/codes/go/pkg/print_utils.go +++ b/codes/go/pkg/print_utils.go @@ -11,7 +11,8 @@ import ( "strings" ) -func PrintSlice(nums []int) { +// PrintSlice Print a slice +func PrintSlice[T any](nums []T) { fmt.Printf("%v", nums) fmt.Println() }