Skip to content

Commit

Permalink
Example #7: checking type parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
tisnik committed Jun 13, 2022
1 parent d0ec19a commit 26b1556
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions lesson8/07_type_parameter_check.go
Original file line number Diff line number Diff line change
@@ -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})
}

0 comments on commit 26b1556

Please sign in to comment.