There is an example: https://go.dev/play/p/guzOWRKi-yp

```
func (c *cachedFn[string, V]) Get0() (V, error) {
// var s any
var s string
s = "abc" // error: cannot use "abc" (untyped string constant) as string 
value in assignment
fmt.Printf("cache key: %#v, %T\n", s, s) // cache key: 0, uint8
return c.Get(s)
}
```
I find the generic type of the struct method a bit confusing.
1.  The type `cachedFn[string, V]` does not really constrain the type of  
`s` to **string**. It's actual type is `uint8`
2. And this error is a bit strange. (`s = "abc"  // error: cannot use "abc" 
(untyped string constant) as string value in assignment. ` )


-- 
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/58c92577-cb98-401a-978d-c22a1fb493ccn%40googlegroups.com.

Reply via email to