The code you wrote is using a generic value, but it is not itself generic. 
There is only one instantiated version of the runInt() function, and it 
knows (at compile-time!) that mySet is an map[int]int.

Make that function actually generic - something like:
func testThing[K comparable, V any](m map[K]V) {
        if m[1337] == 1337 {
                print("OK")
        } else {
                print("nope")
        }
}
and you get
./prog.go:xx:yy: cannot use 1337 (untyped int constant) as K value in map 
index 
./prog.go:xx:yy: cannot convert 1337 (untyped int constant) to V

-- 
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/e1f79d1d-3759-4fcc-a5a8-2d1e88599074n%40googlegroups.com.

Reply via email to