From 26b1556a6f3eff95bef63c44f7d7ca5681f2638e Mon Sep 17 00:00:00 2001 From: Pavel Tisnovsky Date: Mon, 13 Jun 2022 08:50:50 +0200 Subject: [PATCH] Example #7: checking type parameters --- lesson8/07_type_parameter_check.go | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 lesson8/07_type_parameter_check.go diff --git a/lesson8/07_type_parameter_check.go b/lesson8/07_type_parameter_check.go new file mode 100644 index 0000000..735f297 --- /dev/null +++ b/lesson8/07_type_parameter_check.go @@ -0,0 +1,18 @@ +// Strong type check applies there! + +package main + +import "fmt" + +func printValue[T any](value T) { + fmt.Println(value) +} + +func main() { + printValue[int]("www.root.cz") + printValue[[]string]('*') + printValue[string](42) + printValue[int](3.14) + printValue[byte](1 + 2i) + printValue[[]byte]([]int{1, 2, 3}) +}